Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DirectX 10 Resource Leak

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?

like image 530
Venus Avatar asked Jun 15 '10 03:06

Venus


1 Answers

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.

like image 130
Blair Holloway Avatar answered Sep 22 '22 01:09

Blair Holloway