Interviews17 answers
What are the generation of Garbage Collection in C# .NET ?
17 Answers
Basically there are 3 generation of garbage collector in c#
1: Generation 0
it is mainly consist of small objects
2: Generation 1
it consist of moderately heavy objects
3: Generation 2
it consist of heavy object
when garbage collector starts for raclaming the memory for newly created object then it fisrt search or try to reclaim the memory from Geneartion 0 then Generation 1 and then Finally genaration 3
rushikesh bulbulePosted Dec 31, 2017, 12:03 AM EST
When a program run a chunk of memory allotted to this program. This memory divide into three part Gen0, Gen1 and Gen2. Gen0 is for small object, Gen1 for Middium object and Gen2 is for large object.
https://interview-preparation-for-you.blogspot.in/2010/10/garbage-collection.html
Khaleek AhmadPosted Feb 6, 2017, 3:18 AM EST
@Shwetalodha just copy pasted form MSDN https://msdn.microsoft.com/en-us/library/ee787088(v=vs.110).aspx
Plagiarism is a culture of C# corner shame.
gupta mishraPosted Nov 24, 2016, 11:20 PM EST
There are three generation in GC(gen 0,gen1,gen2)
gen0 contains short lived object like and gend 1 contain the object which is more libe then gen 0 but not long lived and gen2 contain long lived object .basically this generation is used for heap memory.
Shuvojit HalderPosted Nov 16, 2016, 12:56 AM EST
Geration 0,1,2
Avikshith AradhyaPosted Jun 9, 2016, 3:51 AM EDT
Memory management is the main concern for any application whether application is window based or web based. In .Net, CLR has garbage collector that executes as a part of our program and responsible for reclaiming the memory of no longer used objects. Garbage collector free the memory for objects that are no longer referenced and keeps the memory for future allocations.
Keerthi VenkatesanPosted Jun 7, 2016, 10:32 PM EDT
GenerATION 0,1,2 - Named as Gen 0, 1, 2
Bhuvanesh MohankumarPosted May 30, 2016, 8:44 AM EDT
3 generation of Garbage Collection. are Gen0, Gen1 and Gen2...
Kapi ShivharePosted May 3, 2016, 10:53 PM EDT
3 generation of Garbage Collection. are Gen0, Gen1 and Gen2.
Kapi ShivharePosted May 3, 2016, 10:53 PM EDT
There are 3 generation of Garbage Collection.
Gen0, Gen1 and Gen2
Vivek KumarPosted Apr 17, 2016, 1:57 AM EDT
There are 3 generation of Garbage Collection.
Gen0, Gen1 and Gen2
Vivek KumarPosted Apr 17, 2016, 1:57 AM EDT
Gen0, Gen1 & Gen2 these 3 are generation of Garbage Collection
Pankaj Kumar ChoudharyPosted Feb 21, 2016, 2:38 PM EST
Whenever we create an object it moves to generation 0 .Garbage collector is automatically called whenever there is a need to free up heap memory .So when garbage collector runs it checks whether object is still being used if so it will move it into next generation .The objects which are not being used are marked for garbage collection.Similarly the object is moved from generation 1 to generation 2.The less the the number of objects in generation 1 and generation 2 better is the performance as generation 0 objects are cleaned frequently.
Rajeev PunhaniPosted Jan 27, 2016, 8:09 AM EST
Heap memory is of 2 type: Managed and UnManaged. Garbage collector runs on Managed heap.
It has (generation) GEN 0, GEN 1 and GEN 2. When the object is no longer in use or disposed explicitly, it will collected by GC. GC will clear the heap memory according the generations from GEN 2 to GEN 0.
Rohit JainPosted Jan 22, 2016, 8:56 PM EST
The heap is organized into generations so it can handle long-lived and short-lived objects. Garbage collection primarily occurs with the reclamation of short-lived objects that typically occupy only a small part of the heap. There are three generations of objects on the heap:
•Generation 0. This is the youngest generation and contains short-lived objects. An example of a short-lived object is a temporary variable. Garbage collection occurs most frequently in this generation.
Newly allocated objects form a new generation of objects and are implicitly generation 0 collections, unless they are large objects, in which case they go on the large object heap in a generation 2 collection.
Most objects are reclaimed for garbage collection in generation 0 and do not survive to the next generation.
•Generation 1. This generation contains short-lived objects and serves as a buffer between short-lived objects and long-lived objects.
•Generation 2. This generation contains long-lived objects. An example of a long-lived object is an object in a server application that contains static data that is live for the duration of the process.
Shweta LodhaPosted Jan 21, 2016, 1:19 AM EST
Gen0, Gen1 & Gen2. Garbage collection comes into picture when sufficient memory is not available to create new objects on Heap.
Anil Kumar MurmuPosted Jan 20, 2016, 10:30 PM EST
Gen0, Gen1 & Gen2 are the generations in .net GC. New objects created in Gen0. objects survived on Garbage Collection will be moved to the next generation. GC will be triggered when there is no space in each generations.
Yuvaraj PeriyasamyPosted Jan 19, 2016, 6:22 AM EST










