tags:

views:

44

answers:

2

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?

+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
That's GetPrivateData, not GetParent -- I wonder whether the same holds true for GetParent.
Anteru
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
+1  A: 

Yes, GetParent() adds a reference to the returned objects, so you need to call Release () on them.

Simon Kozlov