Reputation: 3331
#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!
Upvotes: 1
Views: 239
Reputation: 170489
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.
Upvotes: 2