System Namespace
Represents a weak reference, which references an object while still allowing it to be garbage collected.
The common language runtime garbage collection mechanism reclaims inaccessible ( that is, unreachable ) memory allocated to an object. An object becomes unreachable if all references to it become invalid, for example, by setting those references to a null reference ( Nothing in Visual Basic ).
Garbage collection will call an object's Finalize method ( that is, perform finalization ), if there is such a method and if instructed to do so. Once finalization is complete, unpredictable results will occur if the garbage collected object is reacquired somehow and reused.
A directly or indirectly referenced object is reachable, and the garbage collector is not permitted to reclaim it. A reference to a reachable object is called a strong reference.
A weak reference also references a reachable object, which is called the target. A user acquires a strong reference to the target by assigning the value of the Target property to a variable. However, if there are no strong references to the target, the target becomes eligible for garbage collection even though it still has a weak reference.
There can be a delay between the time an object becomes eligible for garbage collection and the time it is collected. If the user attempts to retrieve the target after it has been collected, only a null reference will be retrieved. If the target has not yet been collected, a valid reference will be retrieved.
An object can be used ( that is, be alive ); become unused and eligible for garbage collection ( that is, dead ); then used again ( that is, resurrected ). However, unpredictable behavior results if a resurrected object is accessed after finalization.
A WeakReference object can specify whether the reference to its target be maintained after finalization; that is, whether the weak reference should track the target's resurrection. A weak reference that does not track resurrection is called a short weak reference, and a weak reference that tracks resurrection is called a long weak reference.
GC Finalize