It uses a mark and a sweep algorithm . Simplified version: begins with a review of all the objects to be collected. Then it scans the roots for objects. Any root object is then marked as being used. After that, all other objects are considered garbage. There's a great description of the details in the CLR via C # Jeffrey Richter.
source
share