lua-users home
lua-l archive

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

Am 05.02.2015 um 21:36 schröbte


I'm trying to debug some memory usage issues in a Lua script that I'm
working on.

What's the best way to get the total amount of memory a table is using?

There is a module lua-getsize that adds a `debug.getsize` function which does what you want. Original is here[1], a modified version that fixes some issues and adds compatibility with Lua 5.2 and 5.3 is here[2]. lua-getsize uses PUC-Rio Lua internals, so it doesn't work with LuaJIT. You can combine lua-getsize with the microscope[3] module to get GraphViz images like this[4] (sizes in bytes are in square brackets).