ObjectPtr->release() always necessary?

Started by
4 comments, last by Teric 21 years ago
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!
I am always open to feedback, positive or negative...
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]
Kippesoep
Ok, that''s what I needed to know. Thanks!
I am always open to feedback, positive or negative...
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]
Thank you all :)
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)/

Kippesoep
{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]
find / -name "your base" -exec chown -R us:us {} ;

This topic is closed to new replies.

Advertisement