1.VLD Tools Overview
Visual Leak Detector (VLD) is a free memory leak detection Tool for Visual C + +. His features are: You can get the memory leak point of the call stack, if possible, you can also get the file and line number, you can get full data leakage memory, you can set the level of memory leak report, and is open source free.
2.VLD Download
Http://www.codeproject.com/tools/visualleakdetector.asp
This article is accompanied by a vld1.0 toolkit, which can be used after downloading the unpacked package.
3.VLD installation
Method One:
After decompression to get vld.h, vldapi.h, Vld.lib, Vldmt.lib, Vldmtdll.lib, Dbghelp.dll and other documents. Copy the. h file to the default include directory for Visual C + +, copy the. lib file to the default Lib directory of Visual C + +, copy the Dbghelp.dll to the running directory of your program, and the installation is complete.
Method Two:
After decompression to get vld.h, vldapi.h, Vld.lib, Vldmt.lib, Vldmtdll.lib, Dbghelp.dll and other documents. Copy the. h file and the. lib file to the directory where you want to detect the project file (for this project only), and copy the Dbghelp.dll to the running directory of your program. The installation is complete.
4.VLD use
Vld.h is included in the. cpp file that contains the entry function. The following is an example of the source program (see appendix):
4.1 Adding header Files4.2 Compiling4.3 run in debug mode: View the output information of the VC
Where the memory leak resides |
4.4 View VC output Information
"Warning:visual Leak Detector detected meory leaks!"
4.5 If there is no memory leak, the information for this output is
"No Memory leaks detected"
5. Appendix5.1 Test files
1#include"vld.h"2#include"iostream.h"3#include"stdio.h"4#include"stdlib.h"5#include"string.h"6 7 voidFunction1 (Char*p)8 9 {Ten Char*ptmp =New Char[255]; Onememset (Ptmp,0x0,255); Astrncpy (Ptmp, p,255); - //Delete ptmp; - } the - intFunction2 (void) - { - CharAcstring[] ="This is test!"; + Function1 (acstring); - + return 1; A } at - voidFunction3 (void) - { - Function2 (); - } - in intMainvoid) - { tocout <<"begin ... .. ....."<<Endl; + Function3 (); -cout <<"end ... .... ....."<<Endl; the return 1; *}
View Code5.2 Vld1.0 Kit5.3 Memory leaks on Linux can be detected using the Valgrind tool
Visual C + + memory leak detection-VLD tool usage instructions.