I'm working on an MFC Visual C++ project. As I understand from MSDN, _CrtDumpMemoryLeaks()
should return TRUE
when there are memory leaks.
After noticing it is TRUE, I tried to find the first point in the code where it becomes TRUE. Evidently, it is TRUE right from the very start. If I click F10 (step-over) to start debugging the program, and enter _CrtDumpMemoryLeaks()
in the watch window, it shows TRUE even before the first line of code, in the entry point to the program:
extern "C" int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
_In_ LPTSTR lpCmdLine, int nCmdShow)
#pragma warning(suppress: 4985)
{
// call shared/exported WinMain
return AfxWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}
Also, I speculated that maybe the debugging facilities are not initialized at that point and that the TRUE is erroneous. So I set a breakpoint at the first line in the OnInitDialog()
function and there too the value is TRUE.
How come I have memory leaks that early in the program?