VC好用簡單的內存泄露檢測工具 Visual Leak Detector

這幾天對一些老程序進行檢查,發現部分程序都有內存泄露的現象.經過查找比較發現Visual Leak Detector是一個很好用的內存檢測工具 .用這個工具只需要在主運行文件加一句 #include "vld.h"即可,調試時會將內存泄露的情況輸出到調式輸出窗口中.該工具可將內存泄露的情況定位到語句上(可能不會100%準確有效).

以下是使用方法:(英文較簡單,不在翻譯)

Using Visual Leak Detector

This section briefly describes the basics of using Visual Leak Detector (VLD). If your project contains DLLs that you'd like to also check for memory leaks, please see Detecting Leaks in DLLs.

To use VLD with your project, follow these simple steps:

  1. Copy the VLD library (*.lib) files to your Visual C++ installation's "lib" subdirectory.
  2. Copy the VLD header files (vld.h and vldapi.h) to your Visual C++ installation's "include" subdirectory.
  3. In the source file containing your program's main entry point, include the vld.h header file. It's best, but not absolutely required, to include this header before any other header files, except for stdafx.h. If the source file includes stdafx.h, then vld.h should be included after it.
  4. If you are running Windows 2000 or earlier, then you will need to copy dbghelp.dll to the directory where the executable being debugged resides.
  5. Build the debug version of your project.

VLD will detect memory leaks in your program whenever you run the debug version under the Visual C++ debugger. A report of all the memory leaks detected will be displayed in the debugger's output window when your program exits. Double-clicking on a source file's line number in the memory leak report will take you to that file and line in the editor window, allowing easy navigation of the code path leading up to the allocation that resulted in a memory leak.

Note: When you build release versions of your program, VLD will not be linked into the executable. So it is safe to leave vld.h included in your source files when doing release builds. Doing so will not result in any performance degradation or any other undesirable overhead.

資源文件下載:

http://dl2.csdn.net/down4/20070726/26150843748.zip

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章