Posts

Showing posts from September, 2017

Generations of Garbage Collection

The CLR’s Garbage collector (GC) is a generational garbage collector, also known as ephermal garbage collector. It has three generations: Generation 0 : It contains all newly constructed object which are never examined by GC. Generation 1: The CLR, when initializes, selects a budget size in kb for generation 0 . If the creation of an object causes the  generation 0 to surpass it’s budget, garbage colllection is started. The objects which are not collected in Generation 0 are moved to Generation 1 and Generation 0 is emptied. Let’s say the budget of Generation 0 is equal to size of 5 objects. So generation 0 would look like below before creation of object 6: 1 2 3 4 5 After creation of object 6, garbage allocation gets started which deallocates the garbage objects 1, 3 and 5 and moves 2 and  4 adjacent to each other in Generation 1. 2 4 6 7 8 9 10 Generation 0 Generation 1 The budget size of generation 1 is