[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Help needed finding large globals
- From: Alexander Gladysh <agladysh@...>
- Date: Wed, 8 Apr 2009 18:02:17 +0400
> Here's what I finally came up with:
>
> Using table.show from here: http://lua-users.org/wiki/TableSerialization
> and the logging package:
>
> function dumpLargeGlobals()
> if not config.dumpLargeGlobals then return end
> for k,v in pairs(_G) do
> local v2 = table.show(v,"v")
> if v2:len() > 3000 and k ~= "_G" and k ~= "package" then
> logger:debug(table.show({GLOBAL=k,value=v2:len()}))
> end
> end
> end
>
> It's not exact, but it gives me a pretty nice relative benchmark. Here, I'm
> dumping any structure/string whose string representation is > 3K (an
> arbitrary number I chose).
>
> HTH someone else.
Are you sure you do not need to detect large upvalues as well?
Simplest example:
do
local upvalue = { --[[ something large ]] }
function my_function() -- global function
print(tostring(upvalue))
end
end
Upvalue would not be collected until my_function is collected.
HTH,
Alexander.