What are the different generaions of Garbage Collection and
how do they work
Answers were Sorted based on User's Feedback
Answer / komilla shaheen
One feature of the garbage collector that exists purely to
improve performance is called generations. A generational
garbage collector takes into account two facts that have
been empirically observed in most programs in a variety of
languages:
1. Newly created objects tend to have short lives.
2. The older an object is, the longer it will survive.
Generational collectors group objects by age and collect
younger objects more often than older objects. When
initialized, the managed heap contains no objects. All new
objects added to the heap can be said to be in generation
0, until the heap gets filled up which invokes garbage
collection. As most objects are short-lived, only a small
percentage of young objects are likely to survive their
first collection. Once an object survives the first garbage
collection, it gets promoted to generation 1.Newer objects
after GC can then be said to be in generation 0.The garbage
collector gets invoked next only when the sub-heap of
generation 0 gets filled up. All objects in generation 1
that survive get compacted and promoted to generation 2.
All survivors in generation 0 also get compacted and
promoted to generation 1. Generation 0 then contains no
objects, but all newer objects after GC go into generation
0.
Thus, as objects "mature" (survive multiple garbage
collections) in their current generation, they are moved to
the next older generation. Generation 2 is the maximum
generation supported by the runtime's garbage collector.
When future collections occur, any surviving objects
currently in generation 2 simply stay in generation 2.
Thus, dividing the heap into generations of objects and
collecting and compacting younger generation objects
improves the efficiency of the basic underlying garbage
collection algorithm by reclaiming a significant amount of
space from the heap and also being faster than if the
collector had examined the objects in all generations.
A garbage collector that can perform generational
collections, each of which is guaranteed (or at least very
likely) to require less than a certain maximum amount of
time, can help make runtime suitable for real-time
environment and also prevent pauses that are noticeable to
the user.
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / vijay
there r 3 generations. they r gen0,gen1,gen2.when objects r
created and buffer is full then garbage collector is called
and the unnecessary objects r removed based on the
priority.this is first generation ie.,gen0.now new objects
will be created.this generation is called gen1.when this is
also full then the unnecessary will be collected and cleaned.
and when new objects come then old objects will be placed in
gen0 and new objects will be kept in gen1.in this way
process continues and when gen2 also filled completely then
gen0 will be cleaned completely.
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / ravindarjobs
refer this link
http://msdn.microsoft.com/msdnmag/issues/1200/GCI2/default.a
spx
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / ravindarjobs
Komilla Shaheen, Are u mad about Garbage Collection or what?
u just give some guidance to the related topic or list some
popular links has i does.
next time if u want to give answer,just tell what it is,but
dont write pages after pages about that topic.
Thanks & Regards
Ravindarjobs
Is This Answer Correct ? | 2 Yes | 3 No |
which datatype i have to use we i need dynamic size.for eg. empname .in first row it have only five chars.but next row it have 100 chars.
can multiple catch blocks be executed for a single try statement?
Which is better python or c#?
Is c# a strongly-typed language?
What is int parse in c#?
An Array is a Ref Type? what about the array elements which are value type(int,Float...etc)?
Is string a data type in c#?
How big is a float?
What is Satellite Assemblies ?
Is javascript harder than c#?
How do I convert a string to an int in c#?
Is c# an open source language?