Can anybody tell me about Generation of Garbage Collector in .net ?
A Microsoft article on the subject: Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework
You don't generate the garbage collector - the garbage collecter just is.
It fires (at unpredictable times) and clears out any items that are no longer being referenced. You can "Suggest" it might want to work immediately by calling the Collect method on the Garbage Collector, which you can access through System.GC - but this does not guaruntee that it will immediately respond.
Hope that helps.
There are several optimization techniques which Garbage Collector uses. One of them uses generations of objects. Any object on the heap belongs to one of the generations:
- Generation 0 - newly allocated objects. they were never marked for collection yet.
- Generation 1 - objects in this generation survived one sweep.
- Generation 2 - objects in this generation survived more than one sweep.
GC sweeps generations with higher number much less frequently.
garbage collector has 3 generations 0 1 2
the highest generation is 2. In .net the garbage collector is normally invocked implicitly but you can force the GC explicitly also.
when first generations is fill i.e 0 GEN & your application wants to store some more value then this GC will invocks & check which elements are in use & which are not & delets the unused element if all the elements are in use then all the elements are transfer to little higher level i.e 1 GEN simliarly to 2 GEN when all the generations are filled & you want to store some more element then GC will throw an exception memory out of range exception .