Weak Reference

Weak references are one of my favorite features of the .NET Framework. As you might guess from the name, a weak reference has less persistence than a strong reference, which is a conventional reference created with the new operator. So long as there is a strong reference for the object, the object persists in memory and cannot be collected. If there is no outstanding reference, the object becomes a candidate for removal in a future garbage collection. Conversely, a weak reference to an object is insufficient to retain that object in memory. A weak reference can be collected as memory is needed. For this reason, you must confirm that weakly referenced objects have not been collected before you use the object.

Weak references are not ...

Get Programming Microsoft® Visual C#® 2008: The Language now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.