What are the different generaions of Garbage Collection and
how do they work

Answers were Sorted based on User's Feedback



What are the different generaions of Garbage Collection and how do they work..

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

What are the different generaions of Garbage Collection and how do they work..

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

What are the different generaions of Garbage Collection and how do they work..

Answer / ravindarjobs

refer this link

http://msdn.microsoft.com/msdnmag/issues/1200/GCI2/default.a
spx

Is This Answer Correct ?    0 Yes 1 No

What are the different generaions of Garbage Collection and how do they work..

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

Post New Answer

More C Sharp Interview Questions

Name the two classes are required for implementing a windows service?

0 Answers  


What is difference between constants and read-only?

0 Answers  


Is learning c# hard?

0 Answers  


What is different between Boxing and Unboxing?

0 Answers  


what is the default access for a class

0 Answers   Cognizant,






What is cache memory in c#?

0 Answers  


Explain anonymous type in c#?

0 Answers  


Explain the steps to create satellite assembly?

0 Answers  


What is the difference between a field and a property in c#?

0 Answers  


Explain ACID rule of thumb for transactions.

3 Answers  


What is the use of the static constructor? When static constructor gets compiled?

1 Answers   Syntel,


How do you sort a list in c#?

0 Answers  


Categories