Garbage Collector in .NET
.net, asp.net, c#-4.0, garbage-collection
Solution
In short: Every application has a set of roots. Roots identify storage locations, which refer to objects on the managed heap or to objects that are set to null.
When the garbage collector starts running, it makes the assumption that all objects in the heap are garbage.
The garbage collector starts walking the roots and building a graph of all objects reachable from the roots.
All objects not reachable are removed (memory is freed)
This is taken from http://msdn.microsoft.com/en-us/magazine/bb985010.aspx - good article about the garbage collection. The "interesting" part for you is "The Garbage Collection Algorithm". It is not a very long section
Problem
How does the garbage collector know the objects and variables are out of scope so they can be collected by garbage collector?