lua-users home
lua-l archive

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


> can I get information from the C API which memory is used by the interpreter? I would like to determine which parts of the LUA script are very memory and "time" expensive, so I can create better code.
> Is there a hook or anything else to get memory / performance information during running?

Use your own memory allocator, not the default one provided by the aux lib.
In Lua 5.2, you even get to know what the memory is being allocated for:

    When ptr is NULL, osize encodes the kind of object that Lua is
    allocating. osize is any of LUA_TSTRING, LUA_TTABLE, LUA_TFUNCTION,
    LUA_TUSERDATA, or LUA_TTHREAD when (and only when) Lua is creating a new
    object of that type. When osize is some other value, Lua is allocating
    memory for something else.