Reference Counting RulesLast reviewed: May 17, 1995Article ID: Q104138 |
The information in this article applies to:
SUMMARYIn the component object model, an interface's lifetime is controlled through reference counting. The reference count for an interface is manipulated through the AddRef() and Release() member functions inherited from IUnknown. The AddRef() member increments an interface's reference count, and the Release() method decrements it. Once an interface's reference count goes to zero, there are no longer any valid pointers to that interface. If the reference count on all of an object's interfaces is zero, then the object can be freed because there are no longer any pointers to the object.
MORE INFORMATION
Reference Counting RulesThe following list is a copy of the reference counting rules (taken from pages 83 and 84 of the OLE 2.0 specification) that must be followed. Small code samples have been added in this article to help clarify the rules.
|
Additional reference words: 2.00 3.50 4.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |