Praveen
What are the generation of Garbage Collection in C# .NET ?
By Praveen in .NET on Jan 16 2016
  • Pankaj  Kumar Choudhary
    Feb, 2016 21

    Gen0, Gen1 & Gen2 these 3 are generation of Garbage Collection

    • 2
  • Shweta Lodha
    Jan, 2016 21

    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.

    • 2
  • Rohit Jain
    Jan, 2016 23

    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.

    • 1
  • Anil Kumar Murmu
    Jan, 2016 21

    Gen0, Gen1 & Gen2. Garbage collection comes into picture when sufficient memory is not available to create new objects on Heap.

    • 1
  • Yuvaraj Periyasamy
    Jan, 2016 19

    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.

    • 1
  • rushikesh bulbule
    Dec, 2017 31

    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

    • 0
  • Khaleek Ahmad
    Feb, 2017 6

    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

    • 0
  • gupta mishra
    Nov, 2016 25

    @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.

    • 0
  • Shuvojit Halder
    Nov, 2016 16

    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.

    • 0
  • Avikshith Aradhya
    Jun, 2016 9

    Geration 0,1,2

    • 0
  • Keerthi Venkatesan
    Jun, 2016 8

    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.

    • 0
  • Bhuvanesh Mohankumar
    May, 2016 30

    GenerATION 0,1,2 - Named as Gen 0, 1, 2

    • 0
  • Kap Shivhare
    May, 2016 4

    3 generation of Garbage Collection. are Gen0, Gen1 and Gen2...

    • 0
  • Kap Shivhare
    May, 2016 4

    3 generation of Garbage Collection. are Gen0, Gen1 and Gen2.

    • 0
  • Vivek Kumar
    Apr, 2016 17

    There are 3 generation of Garbage Collection. Gen0, Gen1 and Gen2

    • 0
  • Vivek Kumar
    Apr, 2016 17

    There are 3 generation of Garbage Collection. Gen0, Gen1 and Gen2

    • 0
  • Rajeev Punhani
    Jan, 2016 27

    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.

    • 0