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:
2020-06-29 15:38:24 +02:00
parent 682dc048e9
commit 78478a203f
6 changed files with 21 additions and 28 deletions

View File

@@ -84,7 +84,8 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
UNREFERENCED_PARAMETER(lpCmdLine);
UNREFERENCED_PARAMETER(nCmdShow);
_CrtSetDbgFlag(_crtDbgFlag | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_LEAK_CHECK_DF);
int res = MsiUseFeature();
assert(!_CrtDumpMemoryLeaks());
return res;
}