Puzzled over memory leaks in MFC project that disappear if _CrtDumpMemoryLeaks() is never called
问题 I have an MFC (C++) dialog-based project that is compiled with Visual Studio 2017. I've added the following code to track for possible memory leaks as I build it: From within ProjectName.cpp before my CWinApp -derived class is initialized. #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> #include <Wtsapi32.h> #pragma comment(lib, "Wtsapi32.lib") struct CatchMemLeaks{ CatchMemLeaks() { HANDLE ghDebugLogFile = ::CreateFile(L".\\dbg_output.txt", GENERIC_READ | GENERIC_WRITE,