_CRTDBG_MAP_ALLOC não mostrando o nome do arquivo
Eu estou tentando detectar vazamento de memória e estou usando fazer macro _CRTDBG_MAP_ALLOC para localizar onde a área de vazamentos. Então estou definindo MACRO como segue:
#ifdef _DEBUG
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__)
#define new DEBUG_NEW
#endif
No meu código, tenho:
UINT SomeFunThread( LPVOID pParam )
{
_CrtMemState crtMemStateStart;
_CrtMemState crtMemStateFinish;
_CrtMemCheckpoint(&crtMemStateStart);
// My suspisious code
_CrtMemCheckpoint(&crtMemStateFinish);
int nDifference(0);
_CrtMemState crtMemStateDifference;
nDifference = _CrtMemDifference(&crtMemStateDifference, &crtMemStateStart, &crtMemStateFinish);
if(nDifference > 0)
_CrtDumpMemoryLeaks();
return 0;
}
(Obrigado a Tushar Jadhav:O consumo de memória aumenta rapidamente e depois cai muito devagar; vazamento de memória?)
Mas a saída mostra algo como:
Detected memory leaks!
Dumping objects ->
{124058} normal block at 0x0000000031DED080, 24 bytes long.
Data: < 0 ` $ > C8 30 F7 EF FE 07 00 00 60 D2 24 1D 00 00 00 00
em vez de algo assim:
Detected memory leaks!
Dumping objects ->
C:\PROGRAM FILES\VISUAL STUDIO\MyProjects\leaktest\leaktest.cpp(20) : {18}
normal block at 0x00780E80, 64 bytes long.
Data: < > CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD CD
Object dump complete.
Então, como posso fazer isso mostrar o nome do arquivo e localização do vazamento?