Toy GC

Jan 12, 2011 13:15


For a project I'm considering, I took a few hours to see if I could write a working garbage collector.

This is a very bare-bones copying GC, written without any reference to How To Do It Properly (just my knowledge of how a copying GC works, but I believe it is mostly cleanly written other than (a) the hardcoded pointer comparisons for object ( Read more... )

c, programming, programs

Leave a comment

Comments 5

atheorist January 12 2011, 19:36:35 UTC
Nice.

Have you seen Darius Bacon's ichbins? The garbage collector is around lines 300-350.

https://github.com/darius/ichbins/blob/master/ichbins.scm

I'd like to be able to write this sort of stuff, but I don't have a sufficiently fuzzy / stressful / realistic test suite to really trust anything that I write. Did you create a test suite as well, or is the "hello world" test case everything?

Reply

kpreid January 12 2011, 20:03:00 UTC
This is all the code there is. I just wrote it in a hurry to decide whether a project which would require something like it was feasible.

Haven't heard of ichbins; might take a look later.

Reply

darius January 12 2011, 23:03:30 UTC
There was a version with a copying GC instead -- this looks like it except for using recursion to copy. (My code ended up taking a couple more lines, so the published one sticks with mark-and-lazy-sweep.)

Reply

kpreid January 12 2011, 23:20:17 UTC
I read it; interesting.

Reply


Leave a comment

Up