If you have ever tried the detection of memory leaks in .NET applications, you probably know that it can be a tricky issue.
One of the common sources of the memory leaks is the
subscription to events, especially if the subscriber is supposed to be a short-lived object. Every such the subscription creates a reference. Since the subscriber object is now referenced, it becomes not collectable by GC and remains in the heap for a long time, or forever, even when no longer used.
The easiest and the most correct solution is not to forget to un-subscribe handler. However, that's not always easy, and in some cases not possible at all.
And here comes an elegant solution from Paul Stovell:
WeakReference event handlers