您的位置:首页 > 其它

不用MFC也可以查内存泄露,简单好用。

2010-07-08 09:41 204 查看
先上代码

// t1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>

int _tmain(int argc, _TCHAR* argv[])
{
_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
int* test=new int[10];
return 0;
}


_CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);就这么一句

然后就是debug了 不是run哦。

然后在输出窗口就可以看到了

Detected memory leaks!

Dumping objects ->

d:/program files/microsoft visual studio 8/vc/include/crtdbg.h(1150) : {110} normal block at 0x003B9BA8, 40 bytes long.

Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD

Object dump complete.

程序“[2760] t1.exe: 本机”已退出,返回值为 0 (0x0)。

40 bytes 10个int没错。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: