https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2441e869638da86106470f...
commit 2441e869638da86106470f51a166acebdb3b3be0 Author: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com AuthorDate: Thu Jun 15 14:27:06 2023 +0900 Commit: GitHub noreply@github.com CommitDate: Thu Jun 15 14:27:06 2023 +0900
[TASKMGR] Report any memory leaks on exit (#5340)
Use the power of CRT debug to detect memory leaks. - Define _CRTDBG_MAP_ALLOC and include <crtdbg.h> after <stdlib.h>. - Call _CrtSetDbgFlag at prologue of wWinMain. CORE-18014 --- base/applications/taskmgr/precomp.h | 5 +++++ base/applications/taskmgr/taskmgr.c | 5 +++++ 2 files changed, 10 insertions(+)
diff --git a/base/applications/taskmgr/precomp.h b/base/applications/taskmgr/precomp.h index 5593f401fcd..872cc76d0ae 100644 --- a/base/applications/taskmgr/precomp.h +++ b/base/applications/taskmgr/precomp.h @@ -9,6 +9,11 @@ #include <stdlib.h> #include <stdarg.h>
+#ifdef _DEBUG + #define _CRTDBG_MAP_ALLOC + #include <crtdbg.h> +#endif + #define WIN32_NO_STATUS
#include <windef.h> diff --git a/base/applications/taskmgr/taskmgr.c b/base/applications/taskmgr/taskmgr.c index 1c754858efa..197b6f82e62 100644 --- a/base/applications/taskmgr/taskmgr.c +++ b/base/applications/taskmgr/taskmgr.c @@ -116,6 +116,11 @@ int APIENTRY wWinMain(HINSTANCE hInstance, TOKEN_PRIVILEGES tkp; HANDLE hMutex;
+#ifdef _DEBUG + // Report any memory leaks on exit + _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); +#endif + /* check wether we're already running or not */ hMutex = CreateMutexW(NULL, TRUE, L"taskmgrros"); if (hMutex && GetLastError() == ERROR_ALREADY_EXISTS)