-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 Leak - Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache #34028
Comments
This issue is lacking enough information for us to be able to fully understand what is happening. Please attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate. |
Sure! I created this example repository with an implementation very close to my real scenario. When I run my application, just the devops/ping route triggered by k8s is enough to cause a constant increase in memory usage. You can simulate these pings directly from the browser console: setInterval(() => fetch('/v1/devops/ping'), 10000);
setInterval(() => fetch('/v1/devops/ping'), 30000); |
Has this issued been looked at or given any time and effort? We can reproduce a large memory usage, but we have yet to create a reproduceable example. |
Something similar is happening in my app; EF Core version: 8.0.6 or EF Core version: 8.0.4 The setup is simple as the database holds 3 tables, from which 2 are in relation in a one-to-many mapping. |
Executed a couple of extra tests and
Who has memory issues please check the suffering apps with pooling. |
Note for team: we need to decide how to best investigate this kind of issue. My usual process doesn't work here, so I'd like to get advice from the team on how to proceed. |
When I start my application, gradually, as processes are executed, the memory consumption just keeps increasing until my k8s pod simply dies due to lack of memory and gets restarted.
After analyzing the generated dumps, we observed the following:
To ensure that the dispose method of my DbContext is always executed, some logs were added during its creation and disposal.
And from these logs, we were able to confirm that the object is indeed always created and disposed without any problems.
In some previous issues, I observed some possible causes within the OnConfiguring method, but I believe that is not the problem in my case.
My DbContext instance is resolved in this way:
The issue was created here because Microsoft.EntityFrameworkCore.Internal.ServiceProviderCache is indicated. But perhaps the problem might be related to the GarbageCollector?
EF Core version: 8.0.6
Database provider: Npgsql.EntityFrameworkCore.PostgreSQL
Target framework: NET 8.0
Operating system: Windows 10
IDE: Visual Studio 2022 17.10.1
My container is running with this base image: mcr.microsoft.com/dotnet/aspnet:8.0
The text was updated successfully, but these errors were encountered: