mardi 29 septembre 2020

_CrtSetDbgFlag not working as expected: returns NULL

I have added below lines of code in application :

#define _CRTDBG_MAP_ALLOC
#include
#include <crtdbg.h>
#ifdef _DEBUG
#define DEBUG_NEW new(_NORMAL_BLOCK, FILE, LINE)
#define new DEBUG_NEW
#endif

and

HANDLE hLogFile;
hLogFile = CreateFileA("c:\\memoryLeaksDump.txt", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, hLogFile);
_CrtSetReportFile(_CRT_ERROR, hLogFile);
_CrtSetReportFile(_CRT_ASSERT, hLogFile);

_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

i don't see any memory leaks detected in the output file. I see below lines printed:

(null)(-1) : atlTraceGeneral - Error 1 in XML File

Can someone me out in resolving the issue and help me in getting the memory leaks

Aucun commentaire:

Enregistrer un commentaire