Ownership You Can Count On: A Hybrid Approach to Safe Explicit Memory Management
Created on 2022-01-28T02:15:38-06:00
Automatic reference counting is cool and good.
But spends CPU cycles managing the counters.
Owning pointer: a single pointer which owns an object.
Non-owning pointer: a single pointer which holds a weak reference.
Owning pointers may permanently transfer to a new pointer (and zero out the old pointers.)
When the owner is lost the object is destroyed. If any weak references remain then throw runtime error.
The type system of the compiler can be employed to help eliminate unnecessary reference manipulations.
NB: I would also prefer proper weak refs which just become tombstones when the owning pointer dies.