Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Teric

ObjectPtr->release() always necessary?

This topic is 5562 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m working with several LPD3DXFONT and LPDIRECT3DTEXTURE8 object pointers in my code. To initialize the LPD3DXFONT objects, I''m using D3DXCreateFontIndirect. For the LPDIRECT3DTEXTURE8 objects, I''m using D3DXCreateTextureFromFile. I''m wondering: is it necessary to explicitly release() these object pointers and then set them to NULL when the program shuts down? Or does the program do it automatically when it shuts down? Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Releasing is always necessary. Setting to NULL isn't (although it's a good way of making sure you don't use the [invalid] pointer anymore)



[edited by - Kippesoep on April 2, 2003 12:59:27 PM]

Share this post


Link to post
Share on other sites
I've read that after the program is terminated all dymanically allocated memmory get's deleted whether u do it urself or not . To what extent is this valid ?
-Edit- typo;

[edited by - Joe Forhens on April 2, 2003 4:09:34 PM]

Share this post


Link to post
Share on other sites
All resources should get deallocated, in theory. In practice, though, this doesn''t always work, especially on Windows 9x (the situation is a lot better on Windows NT/2K/XP, but still not perfect). The deallocation process itself isn''t always perfect, either. I''ve seen plenty of cases where not terminating DX correctly would make it impossible to start any other DX apps. It gets even worse with stuff like GDI resources (which should also be released, but often don''t -- a real problem on 9x class OS''s, which only have 16384 handles for them)/

Share this post


Link to post
Share on other sites
{i'm gonna assume you're using visual studio since you're using d3d}

i recommend using _com_ptr_t or CComPtr for COM object management. They provide hresult->exception support, templated QI methods (casted QI for _com_ptr_t) and IErrorInfo support(i.e. err.raise, err.number, err.description in VB). When working with ativex controls, they become invaluable.



[edited by - null_vector on April 2, 2003 10:25:21 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!