0

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?

Anteru
  • 19,042
  • 12
  • 77
  • 121

2 Answers2

2

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

Simon Kozlov
  • 490
  • 3
  • 6
1

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
  • 5,400
  • 3
  • 19
  • 35
  • That's GetPrivateData, not GetParent -- I wonder whether the same holds true for GetParent. – Anteru Oct 04 '09 at 13:15
  • 1
    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 Oct 05 '09 at 05:48