Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deterministic GC in the CLR?

are there any CLR implementations that have deterministic garbage collection?

Nondeterministic pauses in the MS CLR GC inhibit .Net from being a suitable environment for real-time development.

Metronome GC and BEA JRockit in Java are two deterministic GC implementations that I'm aware of.

But have there any .Net equivalents?

Thanks

like image 244
DayOne Avatar asked Jul 02 '10 11:07

DayOne


People also ask

Is garbage collection deterministic?

Deterministic garbage collection is the ability to specify and maintain a maximum pause time for the memory system with a high level of confidence. It is designed to deliver short, predictable pause times with minimal manual tuning.

What is GC in C#?

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.

How GC decides if objects are live?

GC checks the below information to check if the object is live: It collects all handles of an object that are allocated by user code or by CLR. Keeps track of static objects, as they are referenced to some other objects. Use stack provided by stack walker and JIT.

What are the types of generation in garbage collector?

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 garbage collector stores new objects in generation 0.


1 Answers

There is no way to make the GC deterministic, expect of course from calling GC.Collect() exactly every second using a timer ;-).

The GC however does contain a notification mechanism (since .NET 3.5 SP1) that allows you to be notified when a gen 2 collect is about to happen. You can read about it here.

The GC now also contains multiple latency modes that make it possible to prevent any GC collects from occurring. Of course you should be very careful with this, but is especially useful for real-time systems. You can read more about it here.

like image 119
Steven Avatar answered Oct 13 '22 22:10

Steven