employer cover photo
employer logo
employer logo

Thermo Fisher Scientific

Engaged employer

Thermo Fisher Scientific interview question

How does garbage collection work?

Interview Answer

Anonymous

9 July 2010

Very briefly: The .NET Garbage Collection (GC) sorts the objects by generations (3 total). The lower the generation the more frequently it is checked. During each pass, if an object is referred to by any other object/method GC promotes it to higher generation. Otherwise, it is either destroyed, or marked as needing finalization (will be finalized and destroyed during next pass).