lua-users home
lua-l archive

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


On 16 March 2012 14:37, Jorge <xxopxe@gmail.com> wrote:
> On vie, 2012-03-16 at 09:48 +0100, Axel Kittenberger wrote:
>> But how to approach Lua, is there some list
>> of all allocated objects somewhere? Or some info How much memory the
>> Lua VM needs?
>
> Dumps state:
> http://lua-users.org/lists/lua-l/2006-07/msg00110.html
>
> What about a huge dot graph:
> http://lua-users.org/lists/lua-l/2009-11/msg00491.html
>

We used this for detecting in-Lua "leaks" in Prosody. I improved the
script and maintain it here:
http://code.matthewwild.co.uk/luatraverse/

I also developed a small Lua module to use alongside this which
figures out the size of various objects:
http://code.matthewwild.co.uk/lua-getsize/

In Prosody we then have a plugin that loads these modules and dumps
the Lua state graph to a text file, which users can send to us to view
and debug.

Apologies in advance - there is no proper documentation for either
library, and compiling getsize.c requires access to an actual source
tree of Lua (it uses private headers). I'd also like to suppress in
advance any further complaints about getsize.c injecting itself into
the debug library. If this is a problem for you like it appears to be
for some people, change it.

Hope this helps - if you do decide to use these and get stuck, just let me know.

Regards,
Matthew