Archived

This topic is now archived and is closed to further replies.

Catching leaks in MFC?

This topic is 5097 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I have some memory leaks in my mfc program, and I''m trying to find out where they are. I''ve read I''m supposed to include something like: #define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> and then add another statement at the beginning of my program, but I don''t know where the ''beginning'' is for MFC. I tried adding _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); in numerous places in the main app file, but I didn''t get anything.

Share on other sites
http://gha.booleangate.org/archive/Detecting_and_isolating_memory_leaks_using_MS_VC++.html

Share on other sites
Yes, I''ve already seen that and it hasn''t helped me.

Share on other sites
Are you running in debug mode?

Share on other sites
I get this output:
Dumping objects ->{48} normal block at 0x00C52638, 33 bytes long. Data: < C              > 00 43 00 CD CD CD CD CD CD CD CD CD CD CD CD CD {47} normal block at 0x00C525D0, 40 bytes long. Data: < |L             > 14 7C 4C 10 16 00 00 00 00 00 00 00 00 00 00 00 Object dump complete.

So I put _CrtSetBreakAlloc(48); at the beginning of InitInstance() in my main app file, but it didn't do anything.

[edited by - Sfpiano on February 8, 2004 12:22:13 PM]

Share on other sites
This might be a useful article to read. It might be more then what you need but hey it is pretty simple to implement.

Richard Dickerson

Pikestriker Games

"Kids you tried hard and failed miserably, lesson learned never try" - Homer Simpson