Friday 15 January 2010

c++ - Not able to see memory leak on console -


I am using Visual Studio 2010, try to use the CRT library provided by the VC for making leaking Of But I'm not able to see the memory leak printout on the console. Codebase: #include & lt; Iostream & gt; # Include & lt; Vector & gt; #define _CRTDBG_MAP_ALLOC #include & lt; Crtdbg.h & gt; #ifdef _DEBUG #define DEBUG_NEW new (_NORMAL_BLOCK, __FILE__, __LINE__) #define using new DEBUG_NEW #endif namespace std; Int main () {_CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); Int Y = 1; Int x = 2; Int ** superevil = new int * [Y]; For (int i = 0; i

The reason can not be found.

Note that if you have set _CRTDBG_LEAK_CHECK_DF, then you _CrtDumpMemoryLeaks () _CrtDumpMemoryLeaks () , there was no leak yet .

In addition, it only works in the debug which runs through the IDE and output - if any - the dump is done in the output studio in the visual studio, not on the console.

If you remove the call at _CrtDumpMemoryLeaks () and run through the IDE, you will see something similar to the following (I used VS2012): < / P>

Detect Memory Leaks!
Dumping Objects - & gt;
c: \ consoleapplication1.cpp (24): {190} general block 0x004CCAF0, 8 bytes long.
Data: & lt; & Gt; CD CD CD CD CD CD CD CD: \ consoleapplication1.cpp (22): {18 9} general block 0x004 in CCC 0, 4 bytes long.
Data: & lt; L & gt; F.CA 4C 00 - Object Dump Complete

No comments:

Post a Comment