Reputation: 2112
If I have the following:
ID3D11Buffer **buffers; //ID3D11Buffer is a com object
buffers=new ID3D11Buffer* [num];
Then if I do this:
delete[] buffers;
Will the Release()
method of each ID3D11Buffer*
be called automatically, or do I have to call them myself?
Upvotes: 2
Views: 2410
Reputation: 308206
Calling delete
on an array will destroy each element of the array. But since each element is a POD dumb pointer, destructing it doesn't do anything. If you want the COM objects to be released automatically, you should use a smart pointer such as _com_ptr_t or CComPtr.
Upvotes: 9
Reputation: 26853
All delete[] buffers;
will do is free the array containing the pointers to the COM objects. You do need to loop through the array and Release()
each of them by hand.
Upvotes: 8