DirectX 10 Resource Leak
Asked Answered
W

2

6

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?

Winslow answered 15/6, 2010 at 3:48 Comment(0)
M
6

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.

Malign answered 15/6, 2010 at 4:43 Comment(2)
Does this method work with DX10? I'm not seeing any warning messagesWinslow
Answer is irrelevant to DX10, applies to DX9 only when the asker clearly requested DX10 information.Stepdame
P
1

You could use DirectX Control Panel utility as described here. Turn on "Break on Memory Leaks" check box, then you could use "Break on AllocID" to find which resource was not freed.

Publican answered 15/6, 2010 at 4:42 Comment(1)
Answer is irrelevant to DX10, applies to DX9 only when the asker clearly requested DX10 information.Stepdame

© 2022 - 2024 — McMap. All rights reserved.