Transfer of Ownership

Transfer of ownership occurs when one code module gives ownership of a pointer, or other resource which must be deallocated, to another module. A resource is initially owned by the module which allocated it, and the owner is responsible for releasing it. When ownership is transferred, the original owner no longer owns the resource, and must not deallocate it.

Tracking ownership of resources is important in maintaing correct allocation symmetry within a program.

Shared ownership
Shared ownership occurs when more than one module owns a resource. Shared ownership requires some form of reference count, semaphore, or other mechanism to track the number of owners the resource has. The resource must not be released when more than one module owns it; or, if it is, the other owners must have a mechanism to detect that the resource has been released. A common implementation of shared ownership is a smart pointer.