您的位置:首页 > 其它

查找内存泄露的方法

2015-07-26 23:43 253 查看
这样一段小程序:

#define _CRTDBG_MAP_ALLOC //这里是必须要的

#include <iostream>

#include<stdlib.h>

#include<crtdbg.h>//这里是必须要的

using namespace std;

int main()

{

cout<<"test"<<endl;

{

int* pInt = new int(10);

cout<<*pInt<<endl;

}

_CrtDumpMemoryLeaks();//这里是必须要的

system("pause");

return 0;

}

debug的输出如下,

Detected memory leaks!

Dumping objects ->

{119} normal block at 0x003B5D88, 4 bytes long.

Data: < > 0A 00 00 00

Object dump complete.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: