Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generational GC source code

I am studying GC implementations, and I'm currently looking for references and good open-source GC examples to base in.

Is there any good and simple generational GC implementation ? The second best thing would be good resources and guidelines!

Thank you!

like image 587
Waneck Avatar asked Nov 24 '11 02:11

Waneck


People also ask

What are generations in GC?

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.

What is GC in code?

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 many generations does .NET GC?

Generations. The . NET Garbage Collector has 3 generations and each generation has its own heap that that is used for the storage of allocated objects.

Is G1 generational?

The G1 GC is a regionalized and generational garbage collector, which means that the Java object heap (heap) is divided into a number of equally sized regions. Upon startup, the Java Virtual Machine (JVM) sets the region size. The region sizes can vary from 1 MB to 32 MB depending on the heap size.


1 Answers

I've wrote the Qish garbage collector (not really maintained any more, but feel free to ask). It is a free copying generational GC for C (with some coding styles restrictions).

The GCC MELT [meta-]plugin (free, GPLv3 licensed), providing a high level language, MELT, to extend the GCC compiler, also has a copying generational GC above the existing Ggc garbage collector of GCC. Look into gcc/melt-runtime.c

With generational copying GC, generating the application's code in C is quite useful. See my DSL2011 paper on MELT

Feel free to ask me more, I love talking about my GC-s.

Of course, reading the Garbage Collection Handbook: The Art of Automatic Memory Management (Jones, Hosking, Moss) [ISBN-13: 978-1420082791] is a must


(added in 2017)

Look also into Ravenbrook's Memory Pool System which can be used for generational GC.

Look also into the runtime of Ocaml, which has a good (single-threaded) generational GC.


PS. Debugging a generational copying GC is painful.

like image 139
Basile Starynkevitch Avatar answered Sep 28 '22 15:09

Basile Starynkevitch