lua-users home
lua-l archive

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


I agree that reference counting can work well. I've used it extensively in
some C++ projects and I'm using it while doing Cocoa development. On the
other hand...

* Cycles are more common than you might think. Imagine a view system with
pointers from parents to their children and pointers from children to their
parents. The work around in many systems is to sacrifice safety by choosing
not to count some references. Other safe work arounds increase the
complexity of the implementation.

* The overhead of doing reference counting gets expensive for parameter
passing on the stack. A lot of time can be wasted incrementing and
decrementing reference counts. There are work arounds for this but they are
generally more complicated than simple implementations of reference counting
or they sacrifice safety.

Mark-and-sweep is simple and reliable. Its downside is that it is slow to
collect garbage and it is tricky to make incremental.

That being said, I could see a case being made for investigating reference
counting for Lua as an alternative to an incremental, generational, fully
buzzword compliant garbage collector.

Mark

on 5/28/03 10:47 PM, Thatcher Ulrich at tu@tulrich.com wrote:

> In case anyone is interested, I've written down my current thoughts
> about garbage collection (not necessarily specific to Lua), including
> a nice succinct quote by Ken Thompson.  Executive summary:
> ref-counting is good.  Here's the longer version:
> 
> http://tulrich.com/geekstuff/ref-counting-is-good.txt
> 
> I know the Lua authors have said they're working on incremental +
> generational collection.  I don't know how far along that work is, but
> I'm throwing this into the pot in case it's interesting or helpful.
> 
> -Thatcher
>