On Thu, Nov 13, 2008 at 7:16 PM, Evan DeMond <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I've got a wxLua application that freezes when Lua performs garbage
> collection. I suspect that some important piece of the application is
> getting garbage collected - so I need to devise a way to tell what's getting
> garbage collected and when. The __gc metamethod was my first idea, but that
> has to be set from the C API, and can't be set from within Lua, so that
> seems out.
>
> Any other recourse I can take to figure out what's going on here?

You cannot get the list of objects that will be GCed in the next
cycle, but you can get a complete list of wxWidgets objects that will
be garbage collected when there are no more references to them in Lua.

Search for this word: GetTrackedWindowInfo
Here: http://wxlua.sourceforge.net/docs/wxluaref.html

I recommend just printing them out occasionally and see if you are
collecting a lot of objects and add a call to obj:delete() to force
immediate collection. You may need to do this in "for" loops where you
may generate a lot of them since the Lua GC only runs (I may not
remember correctly) for table creation, function calls, and maybe
something else.

You can also call collectgarbage("collect") to force collections at
the end of functions that you know generate a lot of objects that will
be garbage collected. However, I recommend being more proactive with
the :delete() function if you really are generating a lot of them.

Hope this helps,
    John

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to