Search code examples
c++memory-leakscrtdbg.h

Problem when trying to find memory leaks by using crtdbg.h


I am first time trying to use CRT library to detect memory leaks. I have defined #define _CRTDBG_MAP_ALLOC at the begginging of the program. My program is made of classes one struct and main function. In main function i have _CrtDumpMemoryLeaks(); at the end. I tried to follow these Instructions.

And I wanted to get lines where data are allocated that cause memory leaks but I get output like this:

Detected memory leaks!  
Dumping objects ->  
{326} normal block at 0x00E02C40, 8 bytes long.   
 Data: <<#      > 3C 23 E0 00 00 00 00 00    
{322} normal block at 0x00E02CB0, 8 bytes long.   
 Data: <L       > 4C 1F E0 00 00 00 00 00  
{318} normal block at 0x00E02AF0, 8 bytes long.  
 Data: < "      > CC 22 E0 00 00 00 00 00  
{312} normal block at 0x00E02A10, 8 bytes long.  
 Data: < $      > FC 24 E0 00 00 00 00 00  
...

I don't exit anywhere in my program and it allways finishes in main. What can be the cause that I don't get allocation number ? I can add my code if needed.
Thanks for any help.


Solution

  • Ok, It was impossible to answer my question with the information I gave(I am sorry). The problem was that I had a Base class and derived classes. And in the base class I did not have a virtual destructor. Adding virtual destructor fixed my problem and removed all memory leaks.