Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can visual leak detector exclude the false positive memory leaks?

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

like image 263
whossa Avatar asked Nov 21 '25 11:11

whossa


1 Answers

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!

like image 143
whossa Avatar answered Nov 24 '25 10:11

whossa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!