Skip to main content
GameDev.net gamedev.net
🔒 Locked

Proper Resource Disposal :: Managed DirectX

Started by Zipster Jun 6, 2004 at 7:21 AM 3 replies 7.6k views
Original Post
Zipster
Zipster
Sometimes when I exit my managed DirectX application, it will hang inside the main form''s Dispose function (when I break the application, it references the closing bracket). I can only assume that this means it''s having trouble disposing of my DirectX resources. Right now, I have a Direct3D device, a single vertex buffer, and a collection of objects that manage their own index buffer. Each object has a reference to the Direct3D device so it can call DrawIndexedPrimitives. When I add call to Device.Dispose() to the form''s dispose function, when I break the application after it hangs, the breakpoint is on the statement immediately following the Dispose call. This is why I assume there is a problem disposing of the graphics device. I''ve verified that it only hangs when the vertex buffer is created and each object holds a reference to the device. I''m just looking for some suggestions on how to safely dispose of all my resources, and make sure my application doesn''t try to access them after they''ve been disposed of. Also, any ideas as to why it would hang on disposal would be greatly appreciated
3DXD
3DXD
I had the exact same problem and it was because my device dispose was out of order as mohamed suggested to you to look at. In my case it didn''t happen alot maybe 1 out of 20 times but was enough to look into :-)
Zipster
Zipster
I don''t really have that many resources, and even when I add a call to Device.Dispose it hangs, on that very call. Sometimes not for very long, but sometimes for so long that I have to end the process before it''s complete.

Disposing of the vertex buffers and index buffers is no problem, but it really doesn''t like disposing the graphics device. Could it have to do with the device trying to dispose of the vertex/index buffers itself?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.