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:
parent
682dc048e9
commit
78478a203f
@ -125,9 +125,9 @@ 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);
|
||||
g_module.m_instance = hInstance;
|
||||
|
||||
int res = CredWrite();
|
||||
assert(!_CrtDumpMemoryLeaks());
|
||||
return res;
|
||||
}
|
||||
|
@ -41,10 +41,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_peer.m_instance = hinstDLL;
|
||||
} else if (fdwReason == DLL_PROCESS_DETACH)
|
||||
assert(!_CrtDumpMemoryLeaks());
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ 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_peer.m_instance = hinstDLL;
|
||||
|
||||
@ -55,10 +56,6 @@ BOOL WINAPI DllMain(_In_ HINSTANCE hinstDLL, _In_ DWORD fdwReason, _In_ LPVOID l
|
||||
} else if (fdwReason == DLL_PROCESS_DETACH) {
|
||||
if (g_act_ctx)
|
||||
ReleaseActCtx(g_act_ctx);
|
||||
|
||||
// wxWidgets library has some global objects allocating data on heap in constructors,
|
||||
// causing false-positive memory leak reports.
|
||||
//assert(!_CrtDumpMemoryLeaks());
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -162,26 +162,21 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
UNREFERENCED_PARAMETER(nCmdShow);
|
||||
|
||||
int res = 0;
|
||||
_CrtSetDbgFlag(_crtDbgFlag | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
|
||||
// Note: When a debugger is attached to this process, the WlanUIEditProfile() will raise an exception and fail.
|
||||
// It was accidentially discovered, that COM initialization resolves this issue.
|
||||
com_initializer com_init(NULL);
|
||||
|
||||
{
|
||||
// Note: When a debugger is attached to this process, the WlanUIEditProfile() will raise an exception and fail.
|
||||
// It was accidentially discovered, that COM initialization resolves this issue.
|
||||
com_initializer com_init(NULL);
|
||||
|
||||
{
|
||||
// Initialize Windows XP visual styles
|
||||
INITCOMMONCONTROLSEX icc;
|
||||
icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
icc.dwICC = ICC_WIN95_CLASSES | ICC_STANDARD_CLASSES | ICC_LINK_CLASS;
|
||||
InitCommonControlsEx(&icc);
|
||||
}
|
||||
|
||||
pfnWlanReasonCodeToString = WlanReasonCodeToString;
|
||||
|
||||
res = WLANManager();
|
||||
// Initialize Windows XP visual styles
|
||||
INITCOMMONCONTROLSEX icc;
|
||||
icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
icc.dwICC = ICC_WIN95_CLASSES | ICC_STANDARD_CLASSES | ICC_LINK_CLASS;
|
||||
InitCommonControlsEx(&icc);
|
||||
}
|
||||
|
||||
assert(!_CrtDumpMemoryLeaks());
|
||||
return res;
|
||||
pfnWlanReasonCodeToString = WlanReasonCodeToString;
|
||||
|
||||
return WLANManager();
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user