Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Garbage Collection and threshold values of various generations [duplicate]

I downloaded a free copy of the book "Under the hood of .Net Memory Management". In one of the chapter, author mentions the threshold values of various generations which will force the GC to collect that particular generation and all the other child generations. Exact text given below :

The GC runs automatically on a separate thread under one of the conditions below.

When the size of objects in any generation reaches a generation-specific threshold. To be precise, when:

  • Gen 0 hits ~256 K
  • Gen 1 hits ~ 2 MB (at which point the GC collects Gen 1 and 0)
  • Gen 2 hits ~10 MB (at which point the GC collects Gen 2, 1 and 0)

It's worth bearing in mind that the above thresholds are merely starting levels, because .NET modifies the levels depending on the application's behavior.

I wanted to know if there is a way to figure out as what is the current threshold value of say Generation-2 for a given application while it is running.

like image 266
Pawan Mishra Avatar asked May 18 '12 16:05

Pawan Mishra


People also ask

How many generations of garbage collection are there?

Garbage collection primarily occurs with the reclamation of short-lived objects. To optimize the performance of the garbage collector, the managed heap is divided into three generations, 0, 1, and 2, so it can handle long-lived and short-lived objects separately.

How does generational garbage collection work?

The Generational Garbage Collection ProcessBoth survivor spaces start out empty. When the eden space fills up, a minor garbage collection is triggered. Referenced objects are moved to the first survivor space. Unreferenced objects are deleted when the eden space is cleared.

Which generation is not present in garbage collection?

Most objects are reclaimed for garbage collection in generation 0 and do not survive to the next generation.

What is the concept of garbage collection?

Garbage collection (GC) is a memory recovery feature built into programming languages such as C# and Java. A GC-enabled programming language includes one or more garbage collectors (GC engines) that automatically free up memory space that has been allocated to objects no longer needed by the program.


1 Answers

Similar question and another and both say no. I don't see anything in the GC class either.

like image 144
Guvante Avatar answered Nov 15 '22 00:11

Guvante