Mono Class Library: System Namespace

System.WeakReference Class

A weak reference holds a reference to another object but does not prevent the object from being garbage collected. [Edit]

See Also: WeakReference Members

[System.Runtime.InteropServices.ComVisible(true)]
public class WeakReference : System.Runtime.Serialization.ISerializable

Remarks

Garbage collection is the automatic, background process where unused objects are deallocated from memory. Normally, objects that can still be accessed by the program will not be garbage collected. The WeakReference object provides an exception. The reference from a WeakReference object to another object, the target, is not considered when determining whether that object is ready for garbage collection.

That is, an object is elligible for garbage collection when there are no "strong" references to the object.

When the target of a WeakReference is garbage collected, the Target property of the WeakReference is reset to null and the target is no longer accessible to the program.

If the WeakReference is tracking an object's ressurection, the object will still be accessible from the Target property after the object's Finalize method has been called but before the object is cleared from memory.

[Edit]

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0