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:
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.
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.
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.
Most objects are reclaimed for garbage collection in generation 0 and do not survive to the next generation.
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.
Similar question and another and both say no. I don't see anything in the GC class either.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With