Reputation: 3
Can anybody tell me about Generation of Garbage Collector in .net ?
Upvotes: 0
Views: 331
Reputation: 1711
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 .
Upvotes: 0
Reputation: 5123
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:
GC sweeps generations with higher number much less frequently.
Upvotes: 4
Reputation: 6390
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.
Upvotes: 1
Reputation: 69260
A Microsoft article on the subject: Garbage Collection: Automatic Memory Management in the Microsoft .NET Framework
Upvotes: 1