Skip to main content
gamedev.net
🔒 Locked

releaseing resources

Started by Bobboau Feb 27, 2005 at 6:42 PM 0 replies 450+ views
Original Post
Bobboau
Bobboau
does anyone happen to have a good references to all methods that will result in increseing a d3d resource(idirect3dtexture8/9, idirect3dvertexbufer8/9, ect...)'s internal reference count, I have recently just had to go through an ordeal becase I faild to notice that GetCubeMapSurface did this, and there are a number of other similar errors I am fighting that I think are due to a similar problem.
Bobboau, bringing you products that work... in theory
dave
dave
I dont really have any resources, but have lately been investigating this myself and this is what i have learned.

If you declare a COM object like

LPDIRECT3D9 d3d;

No manual referencing counting is done. But when u assign it like so:

d3d = anotherD3d // anotherD3d != NULL;

You should do this:

d3d->Addref();

and when d3d is going to go out of scope u must call:

d3d->Release();

However supposing u do:

d3d = Direct3DCreate9( D3D_SDK_VERSION );

d3d here is Addref()'s for you.

But u MUST still call Release() when the object is going out of scope.

In short, when u manually call Addref(), match it with Release(). Release anything that is given value my a 'create; function.

Whenever u take a copy of a COM object u must Addref() and then Release().

============

Type 'COM Object's Lifetime, Managing a' into ur SDK help file.

My Topic.

Hope this helps.

ace



Topic Locked

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

Sign in to reply to this topic.