Delegate memory leak detection to CRT
_CrtDumpMemoryLeaks() direct call misreports heap allocations owned by globally initialized objects. Using _CRTDBG_LEAK_CHECK_DF delays the memory leak check until after globally initialized objects are destroyed. Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
@@ -57,10 +57,10 @@ BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID l
|
||||
if (fdwReason == DLL_PROCESS_ATTACH) {
|
||||
#ifdef _DEBUG
|
||||
//Sleep(10000);
|
||||
_CrtSetDbgFlag(_crtDbgFlag | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
#endif
|
||||
g_hInstance = hinstDLL;
|
||||
} else if (fdwReason == DLL_PROCESS_DETACH)
|
||||
assert(!_CrtDumpMemoryLeaks());
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user