[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Research on Lua programs with excessive memory consumption
- From: Philipp Janda <siffiejoe@...>
- Date: Sat, 03 May 2014 12:19:51 +0200
Am 02.05.2014 23:21 schröbte Ignacio Burgueño:
I'd love a tool that combines luatraverse, lua-getsize and lua-microscope.
Your wish is my command: I've added an option to microscope which uses
lua-getsize if available in CPATH on userdatas, tables, functions, and
threads (Lua 5.1 only obviously). An example can be seen here[1].
However, I have no idea how an integration with luatraverse would look
like (I do my own traversal), and I have some unresolved issues with
lua-getsize:
* Currently it returns only the size of a userdata's payload without
the size of the userdata value itself (that's 40 bytes here).
* I'm not sure if/how we can encounter a Proto object on the Lua stack.
* It reports 104 bytes for an empty table (which would indicate one
allocated hash slot), but my own measurements show a size of 64 bytes
for empty tables (without any hash slots allocated). I will investigate
further which one is right ...
* For value types it reports the size of the corresponding C type
(lua_Number, int, void*, etc.), not the size of the Lua type which is
always TValue (16 bytes on my machine).
* I'd love support for Lua 5.2+, and maybe a rockspec for Christmas
... ;-)
Regarding memory issues in Lua: The only annoyances I had so far have to
do with tables keeping allocated hash/array slots, even if the keys are
set to nil. This mostly happens with weak tables used as global caches
in my modules (I do that less often now ...).
Philipp
[1]: http://siffiejoe.github.io/lua-microscope/example1_sizes.gif