Maximus wrote:
>Hi,
>I'm having trouble with some memory leaks. I have a class named CDirectX
>that contains all my directdraw functions so I initialize the class in the
>begining of my program:
>CDirectX* cDirectX = new(CDirectX);
>
>After when my program leaves:
>#define SAFE_DELETE(p) { if(p) { delete(p); } }
The macro doesn't accomplish anything useful, as deleting a null pointer is
harmless.
>cDirectX->DD_Term(); // SAFE_RELEASE my directdraw object,surfaces...
What does SAFE_RELEASE do?
>SAFE_DELETE(cDirectX);
>
>Is there somthing wrong or can it be deep within my CDirectX class?
>Here is the output:
>c:\dxengine\mainfrm.cpp(16) : {49} normal block at 0x007C2F68, 132 bytes
>long. // Thats the line where I'm initializing CDirectX
> Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
>Object dump complete.
>The program '[1284] DXEngine.exe: Native' has exited with code 0 (0x0).
MFC is know to dump leaks prematurely, instead of waiting for the CRT to
dump them after all static duration objects have been destroyed. When do you
call DD_Term? If it's from the dtor of some static duration object, in a DLL
that doesn't link to MFC but is used in an MFC app, this could be such a
case.
--
Doug Harrison
Microsoft MVP - Visual C++