问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/30703812/how-to-get-the-current-reference-count-of-an-object