#include "stdafx.h"
#include <string>
#include <stdlib.h>
#include <crtdbg.h>
#include <iostream>
using namespace std;
#ifdef _DEBUG
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#endif
void EnableMemLeakCheck()
{
int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
tmpFlag |= _CRTDBG_LEAK_CHECK_DF;
_CrtSetDbgFlag(tmpFlag);
}
int _tmain(int argc, _TCHAR* argv[])
{
EnableMemLeakCheck();
//_CrtSetBreakAlloc(207);
char* p = new char[100];
//delete p;
getchar();
//_CrtDumpMemoryLeaks();//这个代码好像会输出额外多余的内存分配信息
return 0;
}
C++ Windows原生内存泄漏分析
最新推荐文章于 2024-09-23 16:37:52 发布