Sign in to follow this  
zyrolasting

(DX9 C++) Memory leak on DestroyWindow()

Recommended Posts

zyrolasting    280
I use an OutputDebugString() call for every key point in my application, (I.E. Direct3D init/close or Window created/destroyed) Apparently, everything is fine until I close the app where I see this is output. The lines with "QE" are from my debug string calls.
Quote:
QE - (INFO)(DIN) - DirectInput closed. QE - (INFO)(D3D) Direct3D closed. QE - (ERROR)(WIN) - Window could not be destroyed. The thread 'Win32 Thread' (0x6fc) has exited with code 0 (0x0). DINPUT8: unloaded before all objects released. (cRef:6) Direct3D9: :====> ENTER: DLLMAIN(0125e6e0): Process Detach 00000ddc, tid=0000096c Direct3D9: (INFO) :MemFini! Direct3D9: :====> EXIT: DLLMAIN(0125e6e0): Process Detach 00000ddc D3DX: MEMORY LEAKS DETECTED: 2 allocations unfreed (88 bytes) D3DX: Set HKLM\Software\Microsoft\Direct3D\D3DXBreakOnAllocId=0x291 to debug The program '[3548] Quo_Engine.exe: Native' has exited with code 0 (0x0).
The memory leak never changes from that amount of memory. There are no child windows. I defined _CRTDBG_MAP_ALLOC and included crtdbg.h, but I can't get it to show me the source file when I call for a dump. (How do I get the source name...? I can, can't I?) Overall, I know that my destroy window call had an issue. I just don't know how to find the leak. At least, I only know a tiny bit on how to start. Any ideas?

Share this post


Link to post
Share on other sites
DarthJappie    132
First off, take look at this line:

DINPUT8: unloaded before all objects released. (cRef:6)

It seems memory has still been allocated for DirectInput objects when your application exits.

This line:

D3DX: MEMORY LEAKS DETECTED: 2 allocations unfreed (88 bytes)

indicates it concerns two allocations (2 objects?).

This line:

D3DX: Set HKLM\Software\Microsoft\Direct3D\D3DXBreakOnAllocId=0x291 to debug

indicates you can set a breakpoint on AllocID 0x291 (using the DirectX Control Panel addon, 'directx.cpl'). This allows your debugger to break at the point of allocation of the objects you forgot to free.

Share this post


Link to post
Share on other sites
zyrolasting    280
Quote:
DINPUT8: unloaded before all objects released. (cRef:6)

It seems memory has still been allocated for DirectInput objects when your application exits.


I see that if I'm looking at it in a different context. Originally I thought of it in the scope of entire interfaces, as in, DirectInput was released before Direct3D. I can see what it could mean otherwise though. The thing I have to say about that is that new/delete have never appeared in anything related to it.
I know I am properly releasing interfaces. I don't know what these tiny objects laying behind could be. (See below)

Quote:
D3DX: MEMORY LEAKS DETECTED: 2 allocations unfreed (88 bytes)

indicates it concerns two allocations (2 objects?).


Well, I figured that!

Quote:

D3DX: Set HKLM\Software\Microsoft\Direct3D\D3DXBreakOnAllocId=0x291 to debug

indicates you can set a breakpoint on AllocID 0x291 (using the DirectX Control Panel addon, 'directx.cpl'). This allows your debugger to break at the point of allocation of the objects you forgot to free.


I've done this, but nothing seems to be different. I get the same messages in output and nothing pops up in front of me. I am on the debug runtime, and I have the message output on max. I typed both 291 and 0291 in the form (since 'x' can't go in there), but nothing has changed.

Share this post


Link to post
Share on other sites
Black Knight    769
What D3DX functions are you using??
If you dont have tons you can disable them one by one and find the one leaking.
For example you need to call Release on meshes created with D3DXCreateBox etc.
Or use CComPtr so that Release is called when it goes out of scope.

Share this post


Link to post
Share on other sites
zyrolasting    280
Hey, sorry for the delay.
I believe I found the leak. It was coming from a model class.

However, my DestroyWindow() function is still failing.
I used the Error lookup, and I apparently have an invalid window handle.
This doesn't make sense, given that I am using a consistent window handle that is in a class under my framework. The window was created (and displayed!) under this handle. Does anyone have an idea on why it's not being destroyed?


[Edited by - zyrolasting on November 22, 2008 1:25:12 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this