Brahmaprasad R
Brahmaprasad R

Reputation: 129

How to get the current reference count of an object?

I have a pointer to a COM object (in C++). Is there a way to get the current reference count of the object which the pointer is pointing to?

Upvotes: 3

Views: 6962

Answers (1)

Roman Ryltsov
Roman Ryltsov

Reputation: 69734

Call IUnknown::AddRef and then immediately IUnknown::Release. The value returned by the latter is current count of outstanding references. Note that the value does not have to be accurate, it is informational only.

Upvotes: 11

Related Questions