Claudiu
Claudiu

Reputation: 229491

How can I experiment with garbage collection?

I'm interested in how garbage collection works. I've read up on how some work such as mark-and-sweep, stop-and-copy, generational GC, etc... I'd like to experiment with implementing some of these and comparing their behaviors. What's a good way to get started experimenting with my own? Ideally something in C, Java or Python (although the last two are themselves garbage-collected so it seems it'd be hard to use them...)

Upvotes: 10

Views: 768

Answers (7)

Max Lybbert
Max Lybbert

Reputation: 20039

Parrot has multiple garbage collectors.

Upvotes: 1

Luke Quinane
Luke Quinane

Reputation: 16615

MMTk contains a large set of high performance garbage collectors. It includes:

  • Copying collectors
  • Tracing collectors
  • Reference counting collectors

It also has:

  • Stop the world collectors
  • Concurrent collectors

Since it is a research platform it has some advance collectors such as the generation reference counting collector.

Upvotes: 0

Jamie Love
Jamie Love

Reputation: 5626

Slava Pestov who developes the Factor programming language wrote a number of posts about his implementation of a garbage collector. You can find posts on it with this link:

http://factor-language.blogspot.com/search?q=garbage+collection

in particular start from the post on Sunday, September 24, 2006.

Upvotes: 0

Bill K
Bill K

Reputation: 62789

Fun to play with, but garbage collection is a dark art. Not to make it work, but to make it work with the efficiency that the newest VMs do.

We're talking multi-stage and magic that makes allocations speed more comparable to stack allocations than malloc.

The whole eden concept rocks.

You might want to read some whitepapers on the techniques used.

Here's an article that seems to have a good overview (just from a quick google/scan)

http://www.devx.com/Java/Article/21977/0/page/1

Upvotes: 0

Michael Burr
Michael Burr

Reputation: 340316

Never played with it myself, but the one that always gets mentioned for use with C/C++ is Hans Boehm's.

Upvotes: 14

Nick Berardi
Nick Berardi

Reputation: 54874

the .NET runtime and Java runtime are now open source, so you can experiment with the runtime it self if you want to play around with a current support programming language. However if you wanted to do this yourself you would probably have to create your own runtime which has it's own language.

Upvotes: 2

JesperE
JesperE

Reputation: 64434

Implement your own JVM. Nothing fancy, just the basics. There are lots and lots of programs/compilers/languages which generate JVM code so you have plenty of material to test with.

Upvotes: 0

Related Questions