I have this app written in VB.Net with winforms that shows some stats and pictures on a bigscreen monitor. I also monitor the memory usage of sad app by using this.
Process.WorkingSet64
I know windows does not always report the correct usage but I just wanted to know if I didn’t have any little memory leaks which I had but are solved now. But the first week the memory usage was around 100MB and the second week the memory usage showed around 50MB.
So why did it all of a sudden drop while still running the exact same code?
I can hardly imagine that the garbage collector kicked in this late since the app refreshes every 10 seconds and it has ample time in between those periods to do it’s thing.
Or perhaps there is just better way to get memory usage for a process that is more reliable.
Process.WrokingSet64doesn’t report the memory usage, it omits the memory that is swapped to disk:Even if your system was never low on free memory, you may have minimized the application window, which caused Windows to trim its working set.
If you want to look for memory leaks you should probably use
Process.PrivateMemorySize64instead. Your shared memory is going to contain just executable code and it’s going to remain more or less constant throughout the life of the process, so you should focus on the private memory.