gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Help Wanted > Help needed documenting incremental GC routines + article

#171887 - keldon - Thu Dec 31, 2009 2:52 pm

Download source code

Edit: I somehow uploaded the wrong demo file (a fix has been submitted)

Hi, I wrote an incremental GC routine 18 months ago; I lost the documentation somehow and would like some help writing new documentation as well as creating an article on how to code garbage collection algorithms.

Code purpose
This can be used to add incremental garbage collection to your own scripting languages, or integrated into code for any structures that would be better handled by such a system.

Demo code

I had some really nice demonstration code that used the GC system to build a number of structures and delete them in incremental steps, but that is unfortunately lost too. I will code them back in at some point, but for now the code is there. Edit: I've uploaded one of the tests here, but this was written before the update so may not be compatible with the more recent code. I'll check this all tomorrow.

Download source code
- Demo code (needs integration)

In short it allows incremental garbage collection by using set partitions and locking mechanisms. The state of a reference is frozen at certain states in the GC in such a way that the GC can be stopped at any time without any complex traversing of the structures.

I haven't looked into it much, but I suspect a generational GC can be created from most of it's logic (or at least structural concept).

I've also included a few basic structures:
- list.cpp - list of objects
- integer.cpp - stores an integer
- fixed_map.cpp - maps 'x' keys
- map.cpp - maps keys to
- var.cpp - flexible variable object
- object.cpp - base class

Unfinished structures:
- fixed_list.cpp

---
I have uploaded it in this unfinished state for the following reasons:
- to make me accountable to following it up; making things public is good, it's far too easy to stop work on something nobody knows about
- get the ball rolling
- even without the documentation, I haven't seen any code on the net like this so it should be helpful
---

Other notes
Root handles aren't deleted by the garbage collector, neither are any objects that are owned by the root. These are the important handles!

Edit: Oh dear, I nearly deleted this post with Ctrl+W ... saved by Chrome ... phew =)


Last edited by keldon on Fri Jan 01, 2010 8:48 pm; edited 1 time in total

#171905 - keldon - Fri Jan 01, 2010 1:32 pm

p.s. I don't mean "writing the source code documentation for me" but rather with me in the sense that my aim is to show people how it works and how to write their own. My "documentation" is outside of the source files on paper. I'll be updating the source code documentation myself, but I want to explain it well.

This is open to anyone who is interested; I could do it but I'd like another head on this for the sake of better communication. Mostly I'd like to know what someone else thinks when looking at the documentation and if they can understand how to write their own.

Oh, and as far as I tested it; it works pretty well. Do your "stuff" and just tell it how many GC steps you want it to process. I'll be adding a demo today =)

#171914 - keldon - Fri Jan 01, 2010 8:50 pm

I've uploaded the updated code with a demo, compile error fixes and filename changes from .h to .hpp.

Download v0002 source code

The file is a VS2008 Express project with an executable inside.

#172015 - vuurrobin - Fri Jan 08, 2010 11:11 pm

so if I understand correctly, you want help with documenting the GC algorithm so people can implement it themself?


I'm not great at documenting algorithms, but if you need help with proofreading or something (and I have time), then I would be willing to help.

I'll also try out the source and demo you posted when I have time.
_________________
my blog:
http://vuurrobin.100webcustomers.com/

#172032 - keldon - Sun Jan 10, 2010 5:56 pm

Yes, I want some help in explaining how the GC system operates (on a whole) so that people will know how to design their own GC - in the form article (so less need for help documenting, more help on the article). Any help will be appreciated, even if it is a list of questions - then I will have a starting point.

Anyone who is curious about GC and developing scripting languages or virtual machines can benefit from an explanation.