lua-users home
lua-l archive

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



On 17-Oct-05, at 7:59 PM, David Given wrote:


Yes, it does sound a bit of a nightmare --- I wasn't aware that libgc didn't support soft references, for example. Even so, it might be instructive to try benchmarking Lua running its own garbage collector on top of libgc; it'd be interesting to know in what way it behaved differently. It's also something that might be done in the real world, if you happened to write an application
that embedded Lua and also used libgc.

It's not exactly that libgc doesn't support "soft references". You can implement a weak pointer with libgc, which is why I was careful to point out that a weak table is not just a collection of weak references. A weak table is somewhat more like a collection of ephemerons, but afaik there is no simple way to implement ephemerons with libgc. If there is, it would be somewhat more attractive, although the other stuff I mentioned would still be a problem.

Personally, I don't really think that libgc is the way to go here, though, although as you say it might be handy in an environment which happened to be using libgc anyway. There are various ways to at least get libgc to not get in the way of Lua's garbage collecting, like having Lua tell it that it is managing its own memory, thank you very much.