Reclaiming Vertex Buffer memory

Started by
8 comments, last by Evil Steve 16 years, 3 months ago
Another noob directX question. I am using directX 9. Each object has a vertex buffer created using the CreateVertexBuffer method and then copying vertex information into it. Everything works and it renders fine. My question is, after I am done using the object (and the associated vertex buffer), I want to properly reclaim all memory allocated to the object. How do I reclaim the memory used by my vertexbuffer (LPDIRECT3DVERTEXBUFFER9)? (is that what Release() does) Thanks.
Advertisement
Call its Release() method.
Thanks!
On a somewhat related topic, is there a similar method (is it FreePrivateData) to reclaim memory for a texture (IDirect3DTexture9 ) that is no longer in use.

Thanks again.
use ->Release(); again :)
Thanks!I'm noticing a trend :)
Use SAFE_RELEASE(object) macro to make sure that you are actually have a memory allocated before releasing. What it does is simply:

if(object) object->Release();

Ofcourse not all D3D objects have release methods so check beforehand.
Quote:Original post by Dynx
Ofcourse not all D3D objects have release methods so check beforehand.
What ones don't? I can't think of any D3D or D3DX object (class / interface rather than a struct) that doesn't, since it's all COM based, meaning everything derives from IUnknown, which contains the Release() function.
Quote:
Use SAFE_RELEASE(object) macro to make sure that you are actually have a memory allocated before releasing. What it does is simply:

if(object) object->Release();

Ofcourse not all D3D objects have release methods so check beforehand.

CComPtr<T> is a better choice.
Quote:Original post by Evil Steve
Quote:Original post by Dynx
Ofcourse not all D3D objects have release methods so check beforehand.
What ones don't? I can't think of any D3D or D3DX object (class / interface rather than a struct) that doesn't, since it's all COM based, meaning everything derives from IUnknown, which contains the Release() function.


There are some interfaces in the new Direct3D 10 effect framework that are not derives from IUnknown.

Quote:Original post by Demirug
There are some interfaces in the new Direct3D 10 effect framework that are not derives from IUnknown.
Ah, I'd forgotten about D3D10 stuff.

This topic is closed to new replies.

Advertisement