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

Releasing Objects

Started by Xizor May 28, 2002 at 9:15 PM 0 replies 400+ views
Original Post
Xizor
Xizor
I saw something that made me curious in the DirectX 8.1 SDK C++ help file. Under the help for the SetStreamSource() function I found this line: "This method increments the reference count of the vertex buffer being assigned and decrements the reference count of the previously assigned vertex buffer. When the vertex buffer is no longer needed, set it to NULL. If you fail to do this, the vertex buffer is not released, resulting in a memory leak." Now, here is what I''m not sure on. Lets say I have a pointer to a vertex buffer called pVB with a reference count of 1. If I say pVB->Release() then it deallocates and its gone. Does the quote I posted above mean that I can say *pVB = NULL without calling Release() and it would be gone or am I supposed to call Release, then set it to NULL? This confused me. I just want to know the proper way to deallocate a buffer (or any DirectX object for that matter) in order to insure that it is definitely deallocated. - Xizor -
Xizor -
jaxson
jaxson
What they mean to say is that you should call SetStreamSource with a NULL vertex buffer pointer so that DirectX releases its reference to your vertex buffer. It is written a bit poorly, but that is what they mean. You still need to call Release() yourself on your buffer when you are done with it too.

Topic Locked

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

Sign in to reply to this topic.