Can visual leak detector exclude the false positive memory leaks?

1.9k Views Asked by At

Say, i'm now using the Visual Leak Detector(VLD) to check the memory leak in our service application. And, since lots of the memory allocation occurs in the static object, so I just wonder, Can VLD exclude those false positive memory leaks(it shouldn't be viewed as the real memory leak)

Much appreciated

1

There are 1 best solutions below

0
On

After some investigation, I found this VLD couldn't exclude those false positive memory leaks(such as new in static object) as this also use a global static object in its vld.dll and its dtor will report the possible memory leak. As you couldn't ensure their destructor sequence you couldn't use VLD to detect the memory leak in static object.

However, I also found a by-pass solution, as you could modify the source code of this tool, you could use atexit to register the reportMemoryLeak function in your ctor that will ensure this method got called after the dtor.

And to be frank, this really not that direct, so see this one http://cfc.kizzx2.com/index.php/detecting-memory-leaks-with-windbg-the-modern-and-free-way/ use windbg+DebugCRT heap is okay!