-
Notifications
You must be signed in to change notification settings - Fork 57
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
Memory leaks when using IncludeOptimized and BulkSaveChanges together with PooledDbContextFactory [7.0.100] #546
Comments
Hello @schuettecarsten , The We can see that a So, if the context is never disposed of, the Is it possible for you to try in a development environment and see if the same behavior happens with Best Regards, Jon |
Hi @JonathanMagnan, thank you for the explanation. I have done some tests and the memory leaks go away when I switch from Do not trust the 60 to 80 megabytes value, it's just what I could estimate from task manager while observing the software. I took a memory dump and analyzed it using Jetbrains dotMemory and could see lots of entities held by the |
Hello @schuettecarsten , Thank you for the info, so there is a huge chance that the memory leak is due to the We will continue to look at it, but you might have a few options you might want to try. Clearing the cacheUsing Using IncludeGraph with the most recent versionIt will not fix this issue and will require you to use method such as If you test the |
@JonathanMagnan |
@JonathanMagnan |
I am using IncludeOptimize and BulkSaveChanges together with EFCore 7.0 in my project. I can see memory usage increase over time and figured out that this is caused by using "PooledDbContextFactory" instead of "DbContextFactory". It looks like some references are still being hold internally which are never released because the DbContext instance itself is never released but only resetted by the pool. It looks like this does not work for entities who are loaded by IncludeOptimized extensions.
Are there any known issues about that?
The job usually reads about 730 MB of entity data into memory, processes it, releases DbContext and sleeps for a while. Without normal DbContextFactory, memory usage does not increase. With PooledDbContextFactory, memory usage increases by about 60 to 80 MB on each run, that value seems to match to the size of all entities that are loaded by "IncludeOptimized".
The text was updated successfully, but these errors were encountered: