您的位置:首页 > 其它

vs 检测内存泄漏

2015-08-10 14:51 375 查看
网上有很多这个的说明,我只是总结了一下

#include <assert.h>
#include <iostream>
#ifdef _DEBUG
#define DEBUG_CLIENTBLOCK   new( _CLIENT_BLOCK, __FILE__, __LINE__)
#else
#define DEBUG_CLIENTBLOCK
#endif
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#ifdef _DEBUG
#define new DEBUG_CLIENTBLOCK
#endif //此部分用于使_CrtDumpMemoryLeaks输出内存泄漏文件名和行号信息默认不会输出相关信息

using namespace std;
int main(int argc, char* argv[])
{
int* p = new int;
_CrtDumpMemoryLeaks();
system("pause");
return 0;
}


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