Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connected Service - Entity collection properties should be lazy initialized #45

Open
uffelauesen opened this issue Aug 25, 2016 · 0 comments

Comments

@uffelauesen
Copy link

Imagine an entity with many properties of type DataServiceCollection<>. As an example - our File entity has 126 Properties of type DataServiceCollection<>

The auto-generated proxy will do eager initializing (as part of the construction process) of all these properties for each File entity returned from the server during the materialization process even when they are not needed (have not been expanded). The overhead of this is massive and can lead to an OutOfMemory exception when a lot a Files are handled. It is also very time consuming.

If I substitute the eager initialization of all DataServiceCollection<> properties (in the proxy/Reference.cs) with lazy initialization (like: p == null ? p = new DataServiceCollection…) the memory consumption is kept at a more reasonable level and I can handle loads of File objects. The overall time consumption is also significantly lower.

This change does however require changes to DataServicesClient/OData.Client, as it currently would just trigger the lazy initialization during GETs. Se here: OData/odata.net#662

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants