-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
I can't understand why Asp.net core doesn't seem to be collecting garbage. Last week I let a web service run for a few of days, and my memory usage reached 20GB. GC doesn't seem to be working properly. So to test this I wrote a very simple web method that return a large collection of strings. The application started off using only 124MB, but with each time I called the web method, the memory usage kept getting higher and higher until it reached 411MB. It would have gone higher if I had kept calling the web method. But I decided to stop testing.
My test code was this:
`
[HttpGet]
public async Task<IEnumerable> TestGC() {
const string message = "TEST";
return Enumerable.Repeat(message, 100000000);
}
`
Although I might be overlooking something... To my understanding, the memory usage should not be increasing with every call to this method. After the object is created and sent to the UI, the memory should have been freed.
As you can see from the screenshot below, even after the GC got called, the memory was not released.
Thanks for the help!
Jay