内存泄漏调试(2)——VLD
来源:互联网 发布:超社会 知乎 编辑:程序博客网 时间:2024/06/05 19:51
原创文章,转载请注明出处
目录
- 目录
- Visual Leak DetectorVLD
- 调试过程
Visual Leak Detector(VLD)
Visual Leak Detector(VLD)是一款用于VC的免费开源的内存检测工具,通过内存检测生成相应的报告。
报告内容包括:发生内存泄漏的文件和行号;内存泄漏点的调用堆栈;内存泄漏的完整数据等。
调试过程
环境:VS2015 , vld2.3
vld下载地址:http://vld.codeplex.com/
编译版本安装步骤如下:
- 将vld安装的bin目录下的dbghelp.dll,Microsoft.DTfW.DHL.manifest,vld_x86.dll拷贝到运行的工程目录下(或是添加到环境变量),否则会出现“计算机丢失dbghelp.dll ”和“应用程序无法正常启动(0xc0150002)”的问题;
- 在需要检测内存泄漏的代码文件里#include “vld.h”即可。
源文件安装:
直接下载vld的源程序,将对应的.h文件拷贝到VS的include目录下;将.lid文件拷贝到VS的lib目录下。
可以在安装好的vld目录下编辑vld.ini文件,修改ReportTo = both可以将内存泄漏的报告打印在文件中。
测试用例:
#include "vld.h"int main() { int* p_int = new int(1234); char* p_char = new char('a'); return 1;}
在Debug模式下运行,内存泄漏报告
Visual Leak Detector Version 2.3 installed.
Outputting the report to the debugger and to E:\wzcGit\testleak\testleak\memory_leak_report.txt
WARNING: Visual Leak Detector detected memory leaks!
———- Block 59 at 0x003754D0: 40 bytes ———-
Call Stack:
d:\th\minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp (359): testleak.exe!heap_alloc_dbg_internal + 0x12 bytes
d:\th\minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp (450): testleak.exe!heap_alloc_dbg + 0x15 bytes
d:\th\minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp (491): testleak.exe!_malloc_dbg + 0x15 bytes
d:\th\minkernel\crts\ucrt\src\appcrt\heap\malloc.cpp (18): testleak.exe!malloc + 0xF bytes
f:\dd\vctools\crt\vcstartup\src\heap\new_scalar.cpp (19): testleak.exe!operator new + 0x9 bytes
e:\wzcgit\testleak\testleak\test.cpp (15): testleak.exe!main + 0x7 bytes
f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (74): testleak.exe!invoke_main + 0x1B bytes
f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (264): testleak.exe!__scrt_common_main_seh + 0x5 bytes
f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (309): testleak.exe!__scrt_common_main
f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): testleak.exe!mainCRTStartup
0x77F1EE6C (File and line number not available): kernel32.dll!BaseThreadInitThunk + 0x12 bytes
0x77DC399B (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0xEF bytes
0x77DC396E (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0xC2 bytes
Data:
00 00 00 00 00 55 37 00 00 00 00 00 00 00 00 00 …..U7. ……..
01 00 00 00 04 00 00 00 3B 00 00 00 FD FD FD FD …….. ;…….
D2 04 00 00 FD FD FD FD …….. ……..
———- Block 60 at 0x00375500: 37 bytes ———-
Call Stack:
d:\th\minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp (359): testleak.exe!heap_alloc_dbg_internal + 0x12 bytes
d:\th\minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp (450): testleak.exe!heap_alloc_dbg + 0x15 bytes
d:\th\minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp (491): testleak.exe!_malloc_dbg + 0x15 bytes
d:\th\minkernel\crts\ucrt\src\appcrt\heap\malloc.cpp (18): testleak.exe!malloc + 0xF bytes
f:\dd\vctools\crt\vcstartup\src\heap\new_scalar.cpp (19): testleak.exe!operator new + 0x9 bytes
e:\wzcgit\testleak\testleak\test.cpp (16): testleak.exe!main + 0x7 bytes
f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (74): testleak.exe!invoke_main + 0x1B bytes
f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (264): testleak.exe!__scrt_common_main_seh + 0x5 bytes
f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl (309): testleak.exe!__scrt_common_main
f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp (17): testleak.exe!mainCRTStartup
0x77F1EE6C (File and line number not available): kernel32.dll!BaseThreadInitThunk + 0x12 bytes
0x77DC399B (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0xEF bytes
0x77DC396E (File and line number not available): ntdll.dll!RtlInitializeExceptionChain + 0xC2 bytes
Data:
D0 54 37 00 00 00 00 00 00 00 00 00 00 00 00 00 .T7….. ……..
01 00 00 00 01 00 00 00 3C 00 00 00 FD FD FD FD …….. <…….
61 FD FD FD FD a……. ……..
Visual Leak Detector detected 2 memory leaks (77 bytes).
Largest number used: 11554 bytes.
Total allocations: 16495 bytes.
Visual Leak Detector is now exiting.
- 内存泄漏调试(2)——VLD
- vld调试(内存泄露)
- 内存泄漏工具(VLD)使用说明
- Vld 静态检测内存泄漏
- 使用VLD查找内存泄漏
- Visual C++ 2010 启动内存泄漏检测功能,VLD 内存泄漏检查 都超简单(2)
- 使用Visual Leak Detector(VLD)检测内存泄漏
- C/C++编译器内存泄漏检测工具(vld)
- vld内存泄漏检测工具--Visual Leak Detector (VLD)
- 内存泄漏检测工具--Visual Leak Detector (VLD)
- VS2012+Vld内存泄漏检测工具的安装
- windows 内存泄漏检测工具vld相关
- MFC使用VLD检测内存泄漏
- 内存泄漏调试(1)——CRT
- 辅助工具——内存泄露检测 VLD
- 内存泄露检测—VLD工具
- 内存泄露检测—VLD工具
- 内存泄露检测—VLD工具
- IOS 使用ZipArchive解压文件
- 支付宝”电脑网站支付“接口对接
- android 内存泄露的8个原因
- UE4C++ 设置UMG控件的Slot
- Shell中的if结合正则表达式使用
- 内存泄漏调试(2)——VLD
- OC与JS之间的交互
- 【学习笔记】【python+opencv】疑惑记录
- webuploader 实现文件断点续传
- Java练习题-编写一个线程安全的延迟加载单例模式(懒汉模式)
- 浅谈算法和数据结构: 六 符号表及其基本实现
- 在使用unittest.TestLoader().loadTestsFromNames()加载用例时遇到no attribute named case的问题
- C/C++使用libcurl库发送http请求(get和post可以用于请求html信息,也可以请求xml和json等串)
- 零基础学习Mahout之一:搭建单机环境