monitor memory leak
Reading from book Windows Internals, we should use private bytes to monitor memory leak.
1. I think the reason why not using virtual bytes, is because there may be some shared materials counted as a part of virtual bytes -- like shared library and file map;
2. I think the reason why not using working set, is because sometimes working set is trimmed and sometimes not all committed virtual bytes are in working set -- like demand for zero scenario.
Are my understanding for (1) and (2) correct?
thanks in advance,
Yes, if your system is swapping, then you can't use "working set", since that is not reflecting memory that has been unused for some time [e.g. "lost" allocations that are just sitting there, not actually being used].
As for the virtual bytes, yes, that includes a bunch of "non-allocations" that may grow and shrink depending on various other matters, so don't necessarily indicate a memory leak.
The best way to track memory leaks is to have a "memory leak detecting library" - there are several around.
I am interested in the "memory leak detecting library" you mentioned. Could you recommend some your favorite please? :-)
I am always relying on debug mode on Visual Studio, which will report how many bytes leaked. Is that approach reliable or have some limitations?
Originally Posted by matsp