vc中检测内存泄露的工具VLD(visual leak detector) 转
2013-03-03 23:13
501 查看
Visual Leak Detector(VLD)是一款用于Visual C++的免费的内存泄露检测工具,用户可从http://www.codeproject.com/tools/visualleakdetector.asp下载,该软件以库形式与用户的被测工程一起使用,由于VLD是按LGPL(GNU
LESSER GENERAL PUBLIC LICENSE)协议对外开源,所以使用VLD是安全的,不必担心版权问题。
VcTester是一款适合于VC代码的白盒测试工具,借助它的脚本驱动与脚本桩功能,可以方便的发起各项测试,因为内存泄露通常在特定操作下才发生,将VcTester与VLD配合使用,由VcTester模拟各种应用场景,VLD检测这些使用场合下有无内存泄露。
使用VLD
先从网站下载VLD的zip包,当前最高版本是V1.0,解压后得到vld.h、vldapi.h、vld.lib、vldmt.lib、vldmtdll.lib、dbghelp.dll等文件,把这些所有.h头文件拷贝到VC默认的include目录下,将所有.lib文件拷贝到VC默认的lib目录下,安装工作就完成了。
使用VLD很简单,只须在包含入口函数的CPP或C文件中把vld.h头文件包含进来即可。该include语句要求放在最前面,如果当前工程定义预编译head文件(如stdafx.h),则放在“#include
<stdafx.h>”语句之后就可以了。之后正常编译、按Debug方式运行被测程序,等程序运行结束时,查阅VC的output窗口,会有“Visual
Leak Detector is now exiting.”一句打印信息,在这条件信息之前,如果当前程序没有内存泄露会有“No memory leaks detected.”信息打印,但如果有内存泄露,将有类似如下信息打印:
C:"VcTester21"sample"vc6"SampleMain.c (80): main
crt0.c (206): mainCRTStartup
0x7C816FD7 (File and line number not available): RegisterWaitForInputIdle
Data:
CD CD CD CD CD ........ ........
Visual Leak Detector detected 1 memory leak.
这个信息指明当前发生内存泄露所在的函数及源文件行号,泄露内存块的地址、长度及当前内存值。用鼠标双击指示源码行的提示信息,VC即自动跳转到相应代码行,我们就很方便的知道是哪一行出错了。
可以看出,VLD用起来很简单,对它的实现原理感兴趣的朋友可以阅读VLD源码,也可参考dofty的文章:使用Visual
Leak Detector检测内存泄露。
相关文章推荐
- vc中检测内存泄露的工具VLD(visual leak detector)
- *vc中检测内存泄露的工具VLD(visual leak detector) 转
- vld(Visual Leak Detector) 内存泄露检测工具
- vld(Visual Leak Detector 内存泄露检测工具
- vld(Visual Leak Detector 内存泄露检测工具
- *vc中检测内存泄露的工具VLD(visual leak detector) 转
- 使用Visual Leak Detector for Visual C++ 捕捉内存泄露---Visual C++内存泄露检测—VLD工具使用说明
- vld(Visual Leak Detector) 内存泄露检测工具
- vc6.0内存泄露之检测工具Visual Leak Detector
- VLD(Visual LeakDetector)内存泄露工具的使用
- 介绍一个c++检测内存泄露工具:Visual Leak Detector
- 内存泄露检测工具 Visual Leak Detector
- 内存泄露检测工具 Visual Leak Detector for Visual C++ 2008/2010
- VLD(Visual LeakDetector)内存泄露工具的使用
- 内存泄露检测工具 Visual Leak Detector for Visual C++ 2008/2010
- windows xp vc 内存检测工具 Visual Leak Detector
- 内存检测工具VC内存泄漏检测工具_Visual Leak Detector(转)
- 内存泄露检测工具 Visual Leak Detector for Visual C++ 2008/2010
- (搬运工)内存泄露检测工具 Visual Leak Detector for Visual C++ 2008/2010
- 初识内存泄露检测工具VisualLeakDetector