Concept: Weak reference
A weak reference is a logical reference to an object instance that does not prevent garbage collection for that instance.
Weak references have two properties:
- IsAlive - Determines if the object instance has been garbage collected. This is seldomly used.
- Target - Converts the weak reference into a strong reference, resulting in
null if the object instance has been garbage collected.
Weak references may be strongly-typed or weakly-typed. The only difference is in the type of
: a strongly-typed weak reference has a specific type for the
property, while a weakly-typed weak reference just uses
for the type of the
The CLR WeakReference type
is a weak reference, but is not used by Nito.Weakness for various reasons.
The Nito.Weakness library includes several types that are weak references: