   vector of LPDIRECT3DTEXTURE9
  Hi,I have a question about the functioning of vectors and how this relates to directX's LPDIRECT3DTEXTURE9. I made a vector containing LPDIRECT3DTEXTURE9. I fill the vector by first loading such texture in a 'buffer' and then using push_back. Is is necessary to release the 'buffer' (I hope it is not because if it is it messes up my app :p)ThanksA_B   
  Yes, it is. You must call Release() on all interfaces that you create or AddRef() manually. So at cleanup time, you'll want to loop over each texture in the vector and call Release() on it.;  yesyes I do that but I mean do I have to release the buffertexture itself I 'push_backed' to the vector:buffer->Release();and later:vector[pos]->Release();ThanksA_B   ;Quote:Original post by A_Byesyes I do that but I mean do I have to release the buffertexture itself I 'push_backed' to the vector:buffer->Release();and later:vector[pos]->Release();ThanksA_BYou need to have one Release() for every creation of the texture. You don't need to if you just push_back'd onto a vector, a LPDIRECT3DTEXTURE9 is just a pointer, adding it to a vector will not increase its reference count.You can treat it pretty much like any class allocated with new - you need to delete it exactly once, once you're finished using it.   ;  OK, Thank You   ;  Alternately, use a vector of smart pointers like ATL's CComPtr and let that worry about calling AddRef() and Release().   ;  is that alternatively or preferably?   ;Quote:Original post by A_Bis that alternatively or preferably?Perferably, in my opinion.  It's quite liberating to free yourself from all of the AddRef and Release nonsense. [smile];Quote:Original post by MJPQuote:Original post by A_Bis that alternatively or preferably?Perferably, in my opinion.  It's quite liberating to free yourself from all of the AddRef and Release nonsense. [smile]Yeah, SlimDX is pretty awesome. [grin]   