日志
VLD(Visual Leak Detector)内存泄露库在QtCreator中的安装使用
2019-02-14 17:44
1.下载地址在这 https://archive.codeplex.com/?p=vld(右上角,目前最新版2.5.1)
2.点击安装,没什么好说的 3.关键的来了,配置Qtcreator,在左侧项目->构建环境中修改Include和LIB目录(上一步中的安装目录下的include和LIB路径) 当然如果你不设置能编译通过最好,反正我的是需要这一步的 4.创建一个测试项目Test002,在pro中添加(步骤3和步骤4任选一个就好) win32 { CONFIG(debug, debug|release) { # vld 2.2 downloaded from http://vld.codeplex.com/ VLD_PATH = "C:/Program Files (x86)/Visual Leak Detector" INCLUDEPATH += $${VLD_PATH}/include LIBS += -L$${VLD_PATH}/lib/Win32 -lvld } } 在main.cpp中添加包含 #ifdef _DEBUG #include "vld.h" #endif 5.测试是否安装成功: main.cpp中添加这句(会有内存泄漏) new QWidget(0); 6.运行,关闭时查看内存泄漏信息,类似: Visual Leak Detector read settings from: C:\Program Files (x86)\Visual Leak Detector\vld.ini Visual Leak Detector Version 2.5.1 installed. Outputting the report to the debugger and to D:\LLWJ\Test002\memory_leak_report.txt WARNING: Visual Leak Detector detected memory leaks! Visual Leak Detector read settings from: C:\Program Files (x86)\Visual Leak Detector\vld.ini ---------- Block 3 at 0x003E0D10: 24 bytes ---------- Leak Hash: 0xF7610160, Count: 1, Total 24 bytes Call Stack (TID 5952): MSVCR110D.dll!operator new() d:\mypc\test002\main.cpp (12): Test002.exe!main() + 0x7 bytes...... 若想让debugger信息输出到txt文件,可修改VLD安装目录下的vld.ini,ReportTo = both(默认debugger) 则在程序目录下多出一个memory_leak_report.txt. |
下一篇: 无