Solution A reference count is added to the body class to facilitate memory management. Memory management is added to the handle class, particularly to its implementation of initialization, assignment, copying, and destruction. It is incumbent on any operation that modifies the state of the body to break the sharing of the body by making its own copy. It must decrement the reference count of the original body. Forces resolved Gratuitous copying is avoided, leading to a more efficient implementation.
Sharing is broken when the body state is modified through any handle.
Sharing is preserved in the more common case of parameter passing, etc. Special pointer and reference types are avoided. Design rationale Reference counting is efficient and spreads the overhead across the execution of real-time programs. This implementation is a variation of shallow copy with the semantics of deep copy and the efficiency of Smalltalk name-value pairs.