lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>>>>> "Thatcher" == Thatcher Ulrich <tu@tulrich.com> writes:

    Thatcher> In case anyone is interested, I've written down my
    Thatcher> current thoughts about garbage collection (not
    Thatcher> necessarily specific to Lua), including a nice succinct
    Thatcher> quote by Ken Thompson.  Executive summary: ref-counting
    Thatcher> is good.  Here's the longer version:

    Thatcher> http://tulrich.com/geekstuff/ref-counting-is-good.txt


I didn't found your arguments convincing in the general case (even if
I agree that they are some applications - perhaps some games? - where
refcounting is acceptable, and that coding with refcounting is
*apparently* easy in C). You might also want to study some good
reference books on GC (like Jones&Lins')

The major point against reference counting is circular
references. They are quite common, and actually can appear during
coding (in the sense that you might need them even if at the design
stage you thought that your reference graph is a DAG). Of course,
there are some dirty hacks to refcount circular graphs, but these
remain only dirty hacks which are very difficult to maintain.

I don't think that the Lua mailing list is the good place to discuss
garbage collection in general. There is a mailing list dedicated to
garbage collection which is IMHO a better place to discuss this.

You can glance at the GC list archive on
   http://lists.tunes.org/mailman/listinfo/gclist
and you can subscribe to it by email to gclist-request at
lists.iecc.com

In addition, if you decide, at the design stage, to use a generational
copying GC in C, it is doable, provided you follow some strict coding
guidelines. For example, you could use my Qish runtime (opensource,
LGPL-ed) for that. See http://freshmeat.net/projects/qish or
http://starynkevitch.net/Basile/qishintro.html for more
(unfortunately, Qish is not multi-threaded yet, in the sense that it
does not support several posix thread doing garbage-collected
allocation at once)

I do agree that switching to any moving or copying collector in C once
you have several thousand lines of C code is a nightmare, because such
GC requires by definition strong cooperation with the coder. 

Regards.
-- 

Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
email: basile<at>starynkevitch<dot>net 
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Faïencerie, 92340 Bourg La Reine, France