lua-users home
lua-l archive

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


On 11/18/2014 10:14 AM, Sean Conner wrote:
> If it's not collected, then you are leaking references somewhere.
> -spc (Chasing down stray references isn't fun ... )

I've spent a little time and made a script [1] that traverses a lua
state searching for an object. Unless you mess with the ldblib/lbaselib
functions I can say with confidence that if my script doesn't find it -
it will be garbage-collected.

Example usage:

    local where=require"where"
    local hash
    do
        local t={}
        hash = tostring(t)
        function string.foo()
            t=t
        end
    end
    -- at this point we have no access to t, only to its address
    print(where.where(hash))

Prints: select(2,debug.getupvalue(_G.string.foo,1))
More info on the usage is in the source.

    [1] https://gist.github.com/mniip/70497b2a39b486a120e6

/* mniip */