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
ASP.NET Core 2.2 In-MemoryDB does not free memory even when records are deleted. #16398
Comments
It will not reclaim memory during normal usage. I would question whether it will release memory even under high gc pressure. The database is rooted as a dependency tied to the the service provider so it will be held across contexts. |
@ajcvickers / @divega / @smitpatel - should this move to the EF repo? (Even if by-design.) |
@vishwas-trivedi This is generally not a good way to determine if there is a memory leak since the memory will not be reclaimed in an immediate and predictable manner. |
@ajcvickers Okay, what do you suggest? I know the usual argument here is "GC will kick-in when there is a shortage of memory" but isn't there any better way to handle this without waiting for the memory to become scarce? Regards, |
@vishwas-trivedi If you would like to follow up on how the garbage collector works, then please go to https://github.com/dotnet/coreclr If you would like to pursue the possible leak in EF Core, then please create a small, runnable project/solution or complete code listing that demonstrates the leak even after garbage collection has been forced. |
@ajcvickers Okay, thank you for the suggestion. I was able to confirm that GC does collect the unused memory when forced called. Regards, |
Describe the bug
I tried creating a sample application to test the feature of InMemoryDatabase in asp.net core 2.2, What I found out was that even when you delete a record from in-memory database, the it does not release the memory(confirmed from task manager).
I have created following API to add and delete records from in-memory DB :
My Startup.cs file looks like following :
To Reproduce
Steps to reproduce the behavior:
Expected behavior
It should clear the memory for the deleted records.
Additional Info
VS 2019's Diagnostic Tools shows the similar result, Process memory increases on put but does not decrease on delete.
Question
Have I made any mistake in settings or understanding the in-memory DB?
Is this expected behavior?
Any help would be appreciated.
Regards.
The text was updated successfully, but these errors were encountered: