Are there any rules to obey in releasing directx8 interfaces?

I find some people release interfaces like d3d8 d3ddevice d3dvertexbuffer in reverse order as creating them , but I try reshuffling the releasing order and no problem occur...

so, any critical rule to obey or just a good habit???
Posted on 2003-05-04 02:53:53 by Inya
I'm going to take a wild guess....

All those interfaces are COM interface, each with its own Release method. Each Release method should be responsible for cleaning up its OWN interface.

So I'm going to say it does not matter what order you release in.

/waits for one on the COM experts to tell me I'm wrong. Or maybe I'm right :grin: (purrrr)
Posted on 2003-05-04 13:50:14 by ThoughtCriminal
There has been tradition for releasing resources in the previous order of which you obtained them. This made _very_ much sense in the dark old days of programming, where heap managers were pretty crappy.

I don't know the exact rules (perhaps they're documented somewhere), but... I wouldn't worry too much about strict reverse-order deallocation. If you can do it, that's fine. However, I'd feel weird about stuff like deallocating the DirectDraw object before deallocating it's surfaces and stuff.

Perhaps the DirectX documentation has something to say about all this - hopefully somebody has a better memory than me :grin:
Posted on 2003-05-04 14:21:12 by f0dder
I think it shouldn't matter, since if there's any reference to an object, it won't be deleted. So you can't force deletion of an object while another pointer to it exists (provided you don't mess up the number of Release calls you do, which is easy :)).

Posted on 2003-05-04 14:47:45 by Thomas
Afternoon, Inya.

from DX SDK for 8.1
The Direct3D object is the first object that your application creates and the last object that your application releases.

Apart from the main D3D object, plus your D3D device, anything else can be released in any order.

It's only recommended to unlock resources paired to their lock call.
; lock vertexbuffer A
; lock vertexbuffer B
; unlock vertexbuffer B
; unlock vertexbuffer A

Posted on 2003-05-04 19:11:46 by Scronty
Scronty Rules~~~:o)

And thanks go to other experts

Posted on 2003-05-05 02:07:13 by Inya