Visual Leak detector is a free, robust, open-source Visual C + + memory leak detection system. Visual Leak detector can display a full memory allocation call stack that causes memory leaks, compared to the memory detection mechanism that comes with Visual C + +. Home Address: http://vld.codeplex.com/old version Address: http://www.codeproject.com/Articles/9815/ Visual-leak-detector-enhanced-memory-leak-detectio Download Visual Leak Detector, current version 2.2.3, "Tools" → "Options" → "project reconciliation in the Visual C + + IDE Solution "→" VC + + directory, "Include files" Increase VLD "\include" path, "library file" to increase the VLD "\lib\win32" path, in addition to the dynamic Library "\bin\win32" path has been added to the environment variables in the installation, if not added, You will need to manually copy the files under "\bin\win32" to the Project debug directory. The following records are used: 1. Create a new WIN32 console project; 2. Add the code as follows:
1 2 3 4 5 6 7 8 |
|
#include "stdafx.h" #include "Vld.h"
int _tmain (int argc, _tchar* argv[]) { Char *pbuf = new char[200]; return 0; } |
3. In debug mode, the Output window will have the following information:
The report lists the memory leaks that are in the number of blocks, where the address, the leaked bytes, the call stack, and the memory contents. Double-click the call stack to jump to the same row. 4. In release mode, Visual Leak Detector is not linked. 5.Visual Leak Detector There are some configuration items that can be set to save the memory leak report (file, debugger), copy "\visual Leak Detector" The Vld.ini file under the path is in the debug directory of the project (it needs to be copied to the project directory if it is running in the IDE), and the following items are modified:
Reportfile =. \memory_leak_report.txt
Reportto = Both directly double-click the Debug directory EXE, as shown in the following: The contents of the file are the same as the contents of the Output window.
How to use Visual Leak detector