I am a bit new to using Visual Studio 2013 and am trying to get Visual Leak Detector (Version 2.3) working so that I can check my projects for memory leaks.
I've got it installed and have added C:\Program Files (x86)\Visual Leak Detector\include to my include directories
and C:\Program Files (x86)\Visual Leak Detector\lib\Win32 to my library directories (both for debug mode).
I build and run the following simple program using the debug menu (or hitting f5):
#include <iostream>
#include <vld.h> //visual leak detector
using namespace std;
int main()
{
for (int i = 0; i < 1000000; i++)
int *ptr = new int(100);
return 0;
}
The leak is obvious (and intentional) here, to test the functionality, but this is the report I get back:
Visual Leak Detector Version 2.3 installed.
The thread 0x38ac has exited with code 0 (0x0).
No memory leaks detected.
Visual Leak Detector is now exiting.
The program '[8136] Test.exe' has exited with code 0 (0x0).
Any ideas?
Edit: I should point out that adding
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
To the beginning of my code and
_CrtDumpMemoryLeaks();
right before the end of main(), does in fact cause Visual Studio's built in leak detection to report leaks, however Visual leak detector still follows this report by saying No memory leaks detected and providing no information.
To find memory leaks and inefficient memory usage, you can use tools such as the debugger-integrated Memory Usage diagnostic tool or tools in the Performance Profiler such as the . NET Object Allocation tool and the post-mortem Memory Usage tool.
The primary tools for detecting memory leaks are the C/C++ debugger and the C Run-time Library (CRT) debug heap functions. The #define statement maps a base version of the CRT heap functions to the corresponding debug version. If you leave out the #define statement, the memory leak dump will be less detailed.
Visual Leak Detector is an open-source memory leak detection system for Visual C++. It shows you the complete callstack used for memory allocation has led to the leak at the end of the debugging session.
It looks like to be a bug with VC++2013, it does work when I use the VC++2010 compiler.
Although I can imagine this not being an option for you. If it helps you, you could use the latest beta version v2.4rc2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With