Context:

Some cases of shared aggregation - n:1 association with shared ownership. An object is considered as member (with the obvious restrictions) by one or more other objects at once.

Challenge:

To eliminate the shared resource exactly when no longer in use.

Skill:

Participants:

Client:

Shares ownership over the resource. Responsible for notifying the Resource about the start and end of the association.

Resource:

Manages the reference count. Responsible for actually deleting the Resource (i.e. itself).

Signature:

Inside an existing n:1 hierarchy: Reference Count datum and interface added to Resource. Registration code added to Client.

Used by:

Reference-Counting Smart Pointer, Reference-Counting Proxy.

Scope:

Languages that do not support automatic garbage collection. (General:) control over a partial population.