Memory leak before the creation of CMainFrame

I'm working on a dialog based application. I noticed some memory leak problems so I googled for ways of detecting the leaks and to plug them. From a thread in this forum I noticed the following structure which worked perfectly in a demo program. The idea is (not mine - credit to the genius who came up with it) to create an object of this at the very beginning of the program so it will be the last to be deleted, hence the memory dump at that point.

1
2
3
4
5
struct MemCheck {
   ~MemCheck() {
        _CrtDumpMemoryLeaks();
   }
};


Now my problem.

I put this structure into the header of MyApp, and created an object of it as the first member of MyApp. It correctly removed many of the previously reported leaks but it keeps on reporting the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Detected memory leaks!
Dumping objects ->
{310} normal block at 0x0196E6D0, 27 bytes long.
 Data: <                > F8 F5 F5 00 0A 00 00 00 0A 00 00 00 01 00 00 00 
{309} normal block at 0x0196E670, 29 bytes long.
 Data: <                > F8 F5 F5 00 0C 00 00 00 0C 00 00 00 01 00 00 00 
....
{100} normal block at 0x01964378, 63 bytes long.
 Data: <    .   .       > F8 F5 F5 00 2E 00 00 00 2E 00 00 00 01 00 00 00 
{99} normal block at 0x019642E8, 84 bytes long.
 Data: <    C   C       > F8 F5 F5 00 43 00 00 00 43 00 00 00 01 00 00 00 
{94} normal block at 0x01967B78, 12 bytes long.
 Data: <            > 00 00 00 00 00 00 00 00 00 00 00 00 
Object dump complete.
Detected memory leaks!
Dumping objects ->
{94} normal block at 0x01967B78, 12 bytes long.
 Data: <            > 00 00 00 00 00 00 00 00 00 00 00 00 
Object dump complete.


I then put modified the InitInstance to return FALSE immediately, but memory leak report is exactly the same as above! What am I missing?

1
2
3
4
5
6
7
BOOL MyApp::InitInstance()
{
   _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
   return FALSE;

   ...
}
Last edited on
Hmmm...
Are you sure that the error in this piece of code? Try to use the tools for finding memory leaks.
I use deleaker in such cases. Or you can try vingrad, but I do not like it.
Goodluck!
Topic archived. No new replies allowed.