Waneck
Waneck

Reputation: 2470

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!

Upvotes: 10

Views: 2162

Answers (7)

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.

Upvotes: 6

haggai_e
haggai_e

Reputation: 4820

Although it's not in written in C, the JikesRVM JVM contains several GC implementations, including a couple of generational ones, and I think it's rather simple to understand.

Upvotes: 2

Christoph
Christoph

Reputation: 169693

The Parrot VM also uses a generational garbage collector.

Upvotes: 3

Luke Quinane
Luke Quinane

Reputation: 16615

Java's HotSpot GC

You can look at the various GC implementations provided by the JVM here.

The Memory Management white paper gives an overview of the different garbage collectors implemented in the JVM. Its from 2006 so its missing the new G1 collector details but its a good starting point.

Mon's SGen GC

Mono's new SGen is on github too. Check out the sgen files.

Upvotes: 5

CRM
CRM

Reputation: 4645

The Ovm framework is open source and offers a framework that allows to select several features regarding garbage collection for real-time systems.

According to the website

Includes Minuteman RTGC framework which allows to select from newly supported RTGC features: time-based scheduling (periodic, slack, and hybrid - a combination of both), incremental stack scanning, replication or Brooks barrier, incremental object copy, arraylets, memory usage, and GC pause profiling and tracing.

Although domain specific, it may be a good starting point for your study.

I hope this helps.

Upvotes: 4

sarnold
sarnold

Reputation: 104080

The Boehm Garbage Collector is commonly used for C and C++ projects.

Upvotes: 1

Jay Conrod
Jay Conrod

Reputation: 29721

The V8 project (Javascript engine used in Chrome and Android) is open source and has a simple generational garbage collector.

You can browse the source code online. In particular, look at heap.cc (implementation of the heap and scavenge algorithm), spaces.cc (lower level heap stuff), and mark-compact.cc (full garbage collector).

Upvotes: 3

Related Questions