At the end of my DirectX application I get "The Direct3D device has a non-zero reference count, meaning some objects were not released.". The application is large and not written by me, how can I go about debugging what resources are not being released?
The first step is to turn use the DirectX debug DLLs, via the DirectX Control Panel. (IIRC, these are an optional item when you install the DirectX SDK, so you may need to install them.)
When you next run your application, DirectX should give you more information about what's leaking. Specifically, you'll want to look for a line like this:
D3DX: Set HKLM\Software\Microsoft\Direct3D\D3DXBreakOnAllocId=0x1c17 to debug
allocation id ^^^^^^
Or, like this:
Direct3D9: (WARN) :Memory Address: 00385580 lAllocID=1 dwSize=000047f8, (pid=00000474)
allocation id ^
Once you have an allocation id, you can tell DirectX to break when that allocation occurs in your program, by setting the Break on AllocID
setting in the DirectX Control Panel (or by setting the registry key mentioned above).
Then, it's a matter of examining the callstack to see what DirectX call is involved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With