lua-users home
lua-l archive

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


On Mar 17, 2012, at 3:46 AM, Dimitris Papavasiliou wrote:

>> There's always the venerable printf technique. Add or modify a __gc handler
>> to suspect userdata and tables which prints a debug message on finalization.
> 
> It is generally easy to keep a count of the objects you allocate and
> find what is still alive.  What's harder is finding out _why_ it is
> still alive when you expected it to be collected.  The most usual case
> for me has been explicit references in the registry as you say but
> still I was thinking that if a general-purpose tool could be created
> that would somehow help you get a picture of the lua state and what's
> keeping what alive.

I've thought that it might be nice to have a compile-time option that would extend all Lua memory blocks with a pointer that would be set by the GC to the object that resulted in this object getting marked. Of course, the problem is finding an object from which to start tracing back though I guess a weak table would do the job there.

Mark