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/28/2011 8:56 PM
Given that these user data are number-like and cannot hold references to other objects, I think one approach might be to use reference counting. Also at least within expressions, and for objects created and used only in a single scope, it might be relatively easy to determine their lifetime using static analysis.

It looks like LuaRC/LuaPlus [3, 4] reference counting system might be one possible approach. Does that seem like a good fit for what I've described above? Are there other options or approaches I should know about? How have other people solved this problem? Are these issues being considered at all for main-line Lua development or are they considered out of scope?

[3] Subject: Re: Reference counting patch for Lua 5.1?
http://lua-users.org/lists/lua-l/2007-04/msg00278.html

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.

[1] https://github.com/jjensen/luaplus51-all

-Josh