-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Perf: Reduce static memory footprint #3931
Comments
I ran a more thorough analysis on the latest bits. The scenario I tested was to execute a single query (Northwind Customers) using an external ServiceProvider, followed by disposing and nulling out both the DbContext and ServiceProvider. The results look good: This table shows the managed memory usage at the end of the test program. We can see that we only retain ~2.2KB of objects from the Microsoft.* namespace. Further I experimented with disabling static caching of MethodInfos in LinqOperatorProvider and the retained memory numbers were unchanged. It looks like these are cached at the CLR level. |
@anpete Thanks for doing the new analysis. 2.2 KB sounds really low and the fact that the MethodInfos didn't change anything is very interesting and great news. I am trying to understand the results a bit better, and I have a couple of questions:
|
~13KB without EF in the picture at all (empty ServiceProvider). |
@divega Re: improvements, I suspect it is a combination of improvements and a better experiment :-) |
Team Triage: Based on analysis we are closing this out now as it seems the memory usage is mostly internal .NET caches and there isn't much to be improved within our stack. |
Some ad-hoc testing shows that EF7 currently has a static footprint of around 1 MB. I.e. once a DbContext has been created, used (e.g. to execute some queries), disposed and become unreachable, around 1 MB of the objects allocated by EF won't be freed up.
We believe there are two main classes of items that add up to this footprint:
I am creating this issue to give us a chance to discuss in triage what we can do about this. Here is atentative list of things to consider:
The text was updated successfully, but these errors were encountered: