I cannot explain this diagram: "memory leak" or not?

36 Views Asked by At

I'm having issues trying to understand a memory usage diagram, hopefully someone more experienced in memory management will be able to tell if I'm facing a memory leak problem or not

To perform this test I have a custom PS1 script which will run an endless loop and keep posting a large amount of data every X seconds, quite similar to what I expect in production.

My app is a .NET Core console app running as a Windows Service. There is no usage of third party components, external libraries, native APIs, etc. It is a typical multi-threading app that makes HTTP requests, writes to disk, sends notifications to a front-end app.

Managed vs Unmanaged memory evolution enter image description here

Unmanaged memory freed enter image description here

When the service gets first started it just uses 33 MB. After the first request, it jumps to 100 MB. On each successive request, memory keeps growing at a very slow pace. The smaller digram at the bottom shows the evolution over the night that is when I conducted the test. It also looks like that at some point the memory kind of gets stabilized at 500-600 MB. I see managed memory being collected, not as often as I would expected, but eventually it gets collected. However unmanaged memory follows its own trend, as I said before, kind of growing very slow or even stabilized. On weird cases, almost randomly I would say, the unmanaged memory is freed (see second capture) but eventually it will build up again.

Do you see a memory leak pattern here?

1

There are 1 best solutions below

0
user949050 On

Okay guys, in case someone is facing a similar issue let me share with you the result of my own research.

This is just .NET using as much resources as it can. I'm using Server GC, it works better when you have your app running alone. The proof is that when I started opening a whole bunch of apps, the OS reclaimed that unused memory from my app and the unmanaged memory was returned.

Worstation GC will more eagrly free memory. and the proof to that is when I switched to Workstation GC, my memory usage went from over 200MB to less than 40MB. CPU increased by a little bit, but nothing to worry about.

Hope this explanation helps somebody. Cheers