Free C++ Memory Leak Detection
-
On 25/06/2013 at 11:12, xxxxxxxx wrote:
This isn't related to C4D. But I just found this nice little memory leak detection program. And I thought I'd share it with you C++ developers.
It's free, and super simple to set up and use:http://vld.codeplex.com/The Instructions are bit poor. Probably because they're based on older versions of VS.
So here's my own instructions I made on how to use it:To use VLD In VS 2010 you have to set up VS to use the VLD header and libraries every time you create a new C++ project WARNING!! Using the browse option in VS can add junk to the file paths like this %%%. Watch out for that!!! -Go to View->Property Pages(the properties Manager) -Select VC++ Directories and then select "Include Directories" -Add the include subdirectory folder from the Visual Leak Detector files where you installed it Example: C:\Program Files (x86)\Visual Leak Detector\include -Then select "Library Directories" and add the lib\Win32 folder from the files where you installed VLD Example: C:\Program Files (x86)\Visual Leak Detector\lib\Win32 -Repeat these steps for 64 versions, but select the lib\Win64 subdirectory instead To use VLD with your project, follow these simple steps: In at least one C/C++ source file from your program, include the vld.h header file like this: #include <vld.h> It should not matter which file you add the include statement to. It also should not matter in what order the header is included in relation to other headers. The only exception is stdafx.h (or any other precompiled header). A precompiled header, such as stdafx.h, must always be the first header included in a source file, so vld.h must be included after any precompiled headers. If your program contains one or more DLLs that you would also like to check for memory leaks, then also include vld.h in at least one source file from each DLL to be included in leak detection. Build the debug version of your program. //This is a little test program that leaks memory //It can be used to test is VLD is working #include<iostream> #include<string> using namespace std; #include <vld.h> class MyClass { public: int foo; }; int main() { MyClass *mc = new MyClass(); //Create a memmory leak to test VLD's output system ("pause"); //Wait for user to close the output window return 0; }
-ScottA