Sign in to follow this  
nathan123

Reclaiming Vertex Buffer memory

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this