Welcome friends in the second article of Garbage Collection. Those who have missed the first one can visit here. So in this article i will talk more about Generations.
So In my last article i mentioned GC has 3 generations: Gen 0, Gen1 and Gen 2. If you want to know the max generations used by applicatio
Generation 0 : This is the youngest Generation and all newly created and short lived objects goes under this generation until they are large objects(80000 bytes and above). Large objects goes directly in Generation 2
Generation 1 : Objects that are not reclaimed in Gen 0 promote to Gen 1. This contains short lived objects and kind of buffer between short lived and long lived objects.
Generation 2 : This contains long live objects and objects that are not reclaimed in Gen 1 promote to Gen 2. Data that lives long time in the process like static data and objects that survived in Gen 2 GC remains in Generation 2.
More objects in Gen 0, the more your application is good in performance. In my next article i will be writing about Strong Vs Weak reference and Garbage collector methods
Hope you enjoyed reading this article.
So In my last article i mentioned GC has 3 generations: Gen 0, Gen1 and Gen 2. If you want to know the max generations used by applicatio
n write : System.GC.MaxGeneration.
Now question comes How Generations improves the performance ?
Managed heap is divided into generations so that it is possible to eliminate dead objects by visiting a particular generation. By that way GC doesn't need to traverse complete graph of Heap and that improve performance significantly.Generation 0 : This is the youngest Generation and all newly created and short lived objects goes under this generation until they are large objects(80000 bytes and above). Large objects goes directly in Generation 2
Generation 1 : Objects that are not reclaimed in Gen 0 promote to Gen 1. This contains short lived objects and kind of buffer between short lived and long lived objects.
Generation 2 : This contains long live objects and objects that are not reclaimed in Gen 1 promote to Gen 2. Data that lives long time in the process like static data and objects that survived in Gen 2 GC remains in Generation 2.
More objects in Gen 0, the more your application is good in performance. In my next article i will be writing about Strong Vs Weak reference and Garbage collector methods
Hope you enjoyed reading this article.