开发者

VS2008 Win32 console application debug version does not tell any memory leak

#include <iostream>
using namespace std;

int main()
{

    char* pCh=new char[100];

 开发者_开发问答   system("pause");

    return 0;
}

My test code is very simple, it does has a memory leak? But why I press F5 to debug run, it does not tell me any memory leak? But It did in some application before. Why? about the settings or different project? can any one help? Thanks!


You have to take special steps to enable memory leak reporting - include special headers so that malloc() calls are replaced with malloc_dbg() calls and also call _CrtSetDbgFlag() and pass _CRTDBG_REPORT_FLAG and _CRTDBG_LEAK_CHECK_DF flags there so that leaks are reported when the program terminates.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜