查找内存泄漏问题,new空间未delete

Detected Memory leaks内存泄漏 noraml block at 0x

方法1:

在开辟内存之前加上下面这句,直接运行定位错误:

        CrtSetBreakAlloc(330); //330为上面内存泄漏的块号

运行后查找到问题点:

Detected Memory leaks内存泄漏 noraml block at 0x

方法2:

使用vld插件,下载https://kinddragon.github.io/vld/安装后,加上#include <vld.h>

错误:#error : [VLD COMPILE ERROR] '#include <vld.h>' should appear before '#include <afxwin.h>' in file stdafx.h

解决办法:

在stdafx.h有#include <afxwin.h>

将#include <vld.h>放在#include <afxwin.h>之前,可以解决问题

查看VC输出信息:

 "WARNING: Visual Leak Detector detected meory leaks!"

如果没有内存泄露,此输出的信息为:

      "No memory leaks detected"

Detected Memory leaks内存泄漏 noraml block at 0x

双击定位错误。

相关文章: