内存泄露检测工具【VLD v2.2.3】

来源:互联网 发布:粤贵银软件下载 编辑:程序博客网 时间:2024/05/22 03:23

下载地址:http://vld.codeplex.com/releases/view/82311

完装完成后会提示打开文档,然后会打开一个在线的静态帮助页面,点击Using Visual Leak Detector后有安装帮助,我用的是VC 2010 Express版本(正版的免费编译器可以自己去MS那里下载),不过这个帮助指引写的和我所用的版本有点差异,我写下自己的使用方法:

1)View->Property Manager

2)右键Debug | Win32下的Microsoft.Cpp.Win32.user选Property

3)选VC++ Directories项

4)将VLD目录下的include子文件夹添加到Include Directories里

5)将VLD目录下的lib\win32子文件夹添加到Library Directories里

PS:根据自己的软件选择添加win32还是win64

6)在自己的程序里#include <vld.h>,注意要最后包含这个头文件。

7)如果有泄露会在output窗口显示泄露,这是个例子,只new了一个内存但没有delete:

int main(int argc,char* argv[]){new int;return 0;}

WARNING: Visual Leak Detector detected memory leaks!
---------- Block 1 at 0x003A2BB0: 4 bytes ----------
  Call Stack:
    d:\practice\cpp\t001\test\test\main.cpp (10): test.exe!main + 0x7 bytes
    f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (555): test.exe!__tmainCRTStartup + 0x19 bytes
    f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (371): test.exe!mainCRTStartup
    0x7C817077 (File and line number not available): kernel32.dll!RegisterWaitForInputIdle + 0x49 bytes
  Data:
    CD CD CD CD                                                  ........ ........



Visual Leak Detector detected 1 memory leak (40 bytes).
Largest number used: 40 bytes.
Total allocations: 40 bytes.
Visual Leak Detector is now exiting.
The program '[3504] test.exe: Native' has exited with code 0 (0x0).
原创粉丝点击