System.WeakReference internals and side-effects
After discussing the uses of WeakReference, I decided to dig into the internal implementation in .NET a bit more. I thought I’d write a short bit about how the WeakReference class works internally, and some side effects of using this vs. a standard strong reference.
Working with the GC instead of against it – System.WeakReference in .NET
While garbage collection isn’t the thing that sets .NET above development in C++ in my mind, it is a major factor. The garbage collector in .NET is a wonderful thing. It makes development much cleaner, safer, and more enjoyable in general. Not only do you get great developer productivity boons, you also have a level of safety that just makes writing memory intensive code more fun.
The GC in the CLR is fantastic – until it isn’t. As much as I love the garbage collector, it also can have some pretty nasty side effects, notably causing memory leaks that are sometimes difficult to trace and fairly painful to correct.