|
by Paul Stovell via Paul Stovell on 7/1/2010 11:36:52 AM
A good rule of thumb to live by is that long-lived objects should avoid referencing short-lived objects.
The reason for this is that the .NET garbage collector uses a mark and sweep algorithm to detemine if it can delete and reclaim an object. If it determines that a long-lived object should be kept alive (because you are using it, or because it's in a static field somewhere), it also assumes anything it references is being kept alive.
Conversely, going the other way is fine - a short-lived
... [ read more ]
|