The IDXGIObject
has a function to obtain a pointer to its parent GetParent
. Unfortunately, the docs don't say whether I have to call Release()
on the returned interface or not -- calling or not calling it works fine in both debug/release (that is, no crash), but I wonder whether I should release or rather not. Any idea how this is supposed to work?
views:
44answers:
2
+1
A:
From the MSDN docs "If the data returned is a pointer to an IUnknown, or one of its derivative classes, previously set by IDXGIObject::SetPrivateDataInterface, then ::Release() must be called on the pointer before the pointer is freed to decrement the reference count."
I would recommend calling release.
whatnick
2009-10-04 12:37:57
That's GetPrivateData, not GetParent -- I wonder whether the same holds true for GetParent.
Anteru
2009-10-04 13:15:58
COM's convention is that callers always release returned data. I've written about this here: http://www.winwonk.com/writing/commemory/. Now, DirectX probably won't allow cross-process calls, so I'm not sure if they play tricks with ownership for performance reasons. However, not calling `Release` in this case should yield a memory leak.
Kim Gräsman
2009-10-05 05:48:32
+1
A:
Yes, GetParent() adds a reference to the returned objects, so you need to call Release () on them.
Simon Kozlov
2009-10-21 01:29:29