lua-users home
lua-l archive

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

----- Original Message -----
From: Ross Bencina
Date: 10/29/2011 1:45 AM
On 29/10/2011 6:03 PM, Joshua Jensen wrote:
I can't recall if I ever did a standalone LuaRC 5.1, but the reference
counting is definitely in the LuaPlus [1] source code. Look for
LUA_REFCOUNT and copy the changes into your copy of Lua. It works in
almost all instances, and it is very effective at keeping memory under
control. I also like that it adds deterministic finalization to Lua.

Is there a write-up somewhere of how the LuaPlus reference counting works?
I'm wondering about things like: Does it replace the current Lua GC with reference counting for all objects?
All objects are reference counted. The incremental collector in Lua 5.1 can still be called.
or can it be applied selectively to certain types?
It cannot.
Does it perform cycle detection?
No. If you are going to end up with cycles, you'll need to call lua_gc() on occasion.
How does it performe compared to the standard Lua GC?
Well, the majority of the time, it isn't necessary to call lua_gc() at all. If you never have a cycle, you should never really need to call it.

Weak tables are not handled, if I recall correctly.

In terms of performance, reference counting occurs, and that adds overhead to any TValue manipulation. On the other hand, deterministic finalization means that objects will fall out of scope at an 'end'. Memory is kept under control all the time.

The benchmarks against LuaRC 5.0 [1] look good.

I am unaware of anyone using the reference counting implementation under Lua 5.1.