> Anyone as experience in custom garbage collectors implementations?
There's a custom refcounting garbage collector in XLR, see http://xlr.git.sourceforge.net/git/gitweb.cgi?p=xlr/xlr;a=blob;f=xlr/include/gc.h and http://xlr.git.sourceforge.net/git/gitweb.cgi?p=xlr/xlr;a=blob;f=xlr/gc.cpp. It's relatively straightforward to use, see xlr/include/tree.h for an example of how it's used. Two things to know about:
GARBAGE_COLLECT(ClassName): implements operator new and delete for ClassName
GCPtr<Class>: A smart pointer that serves as a GC root while it's live.
If you know your data structures, it's probably slightly more efficient than a generic approach like Boehm's. Beware that it's not thread safe yet, I never completed writing my "atomic.h" to do that.
> Also, an alternative/complement I consider is to perform escape
> analysis, in order to rely less on a garbage collector. Has someone
> experimented with this?
Yet another alternative that I'm working right now is stronger type inference, in order to "box" and "unbox" values, so that you can allocate many values on the stack or heap.
> Another alternative is Newlisp's ORO (Only Reference Once):
> http://www.newlisp.org/MemoryManagement.html
> However, it seems to put some constrains on the language: passing by
> value is the rule, and passing by reference is an exception that
> requires the user to take some special steps in order to achieve it.
It's a nice design, but I wonder how they ensure the rules in the runtime. There are also things that implicitly create multiple references without a named symbol, e.g. continuations.
Christophe