Counting Proxy Pattern

A Counting Proxy can be used for collecting usage statistics, or to implement a well-known technique for automatically deleting obsolete objects-reference counting. To achieve this the counting proxy maintains the number of references that exist to the original, and deletes the original when this number becomes zero. You need to ensure that there is exactly one counting proxy for every original, and that every access to an original goes through a defined interface of the respective proxy.

See: Proxy

Partha Kuchana describes Smart Reference and Counting Proxy in a confusing way in his pattern book.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License