Weak References and Finalization
Created on 2020-07-31T22:07:34.600459
Reference: A marker which says an object is still in use. These are counted and something is deleted when it no longer has any references to it.
Weak Reference: A marker which references an object but does not "count" as a reference. When the object it references is deleted the weak reference is replaced with a tombstone. Allows an object to reference another without keeping it alive.
Finalizer: A piece of code which is run when an object is deleted because it no longer has any references to it.
The appropriate time to use a finalizer is when an object holds external resources.
Dolphin Smalltalk
- #beFinalizable marks an as having a finalizer, #beUnfinalizable removes it.
- If an object is finalizable then the #finalize message is passed to it upon destruction.