使用 VLD 内存泄漏检测工具辅助开发时整理的学习笔记。
【资料图】
在 QT 中使用 VLD 的方法可以查看另外几篇博客:
【Visual Leak Detector】在 QT 中使用 VLD(方式一)、
【Visual Leak Detector】在 QT 中使用 VLD(方式二)、
【Visual Leak Detector】在 QT 中使用 VLD(方式三)。
本次测试使用的环境为:QT 5.9.2,MSVC 2015 32bit,Debug模式,VLD 版本为 2.5.1,VLD 配置文件不做任何更改使用默认配置,测试工程所在路径为:E:\Cworkspace\Qt 5.9\QtDemo\testVLD
。
写一个简单的无内存泄漏的程序,如下:
#include #include "vld.h"int main(int argc, char *argv[]){ QCoreApplication a(argc, argv); return a.exec();}
程序运行结束后,并没有检测到内存泄漏,VLD 会输出以下 4 行报告:
Visual Leak Detector read settings from: D:\Program Files (x86)\Visual Leak Detector\vld.iniVisual Leak Detector Version 2.5.1 installed.No memory leaks detected.Visual Leak Detector is now exiting.
第 1 行表示 VLD 读取的配置文件路径,可以根据路径找到该文件,然后更改里面的相关配置,获得想要的效果。
第 2 行表示 VLD 2.5.1 在程序中初始化成功。
第 3 行表示本次运行没有检测到内存泄漏。
第 4 行表示 VLD 正常退出。
关键词: