Qt use Visual C ++ memory leak detection tools (VLD)

The VLD
the VLD (Visual Leak Detector) is a free memory leak detection tool for the Visual C ++. Compared to other memory leak detection means, which detect memory leaks, while also having the following characteristics:

可以得到内存泄漏点的调用堆栈,如果可以的话,还能得到其所在文件及行号;
可以得到泄露内存的完整数据;
可以设置内存泄露报告的级别;
它是一个已经打包的 lib,使用时无须编译源码。对于使用者自己的代码,只需要做很小的改动;
源码使用 GNU 许可发布,并有详尽的文档及注释。对于想深入了解堆内存管理的读者,是一个不错的选择。

Visible, VLD easy to use. Only need minor changes (add a library and include the header file), then run your program properly, you can find memory problems; if depth source, you can learn the principles of heap memory allocation and deallocation of memory leak detection principle and common operating memory skills.
Download, install
https://kinddragon.github.io/vld/

After installation file folder include:
bin: contains dbghelp.dll, vld_x86.dll file
include: contains vld.h, vld_def.h file
lib: file contains vld.lib

QT used VLD

1, adding the library file in the pro

win32: LIBS += -L$$PWD/'../../../../Program Files (x86)/Visual Leak Detector/lib/Win64/' -lvld
INCLUDEPATH += $$PWD/'../../../../Program Files (x86)/Visual Leak Detector/lib/Win64'
INCLUDEPATH += $$PWD/'../../../../Program Files (x86)/Visual Leak Detector/include'
DEPENDPATH += $$PWD/'../../../../Program Files (x86)/Visual Leak Detector/lib/Win64'

2、

#include "mainwindow.h"
#include <QApplication>
#include <vld.h> //加入头文件

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    char *name = new char[5];
    return a.exec();
}

3, the effect
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/u011370855/article/details/88409602