See this thread on the Lua list for a current discussion about some
related problems with Lua's GC and userdata.

http://lua-users.org/lists/lua-l/2008-11/msg00262.html

Also note that you can tweak up the collector to make it more
aggressive, but getting the right values is a trial and error process
as the values of setpause and setstepmul are not simple.

See the collectgarbage() function
http://www.lua.org/manual/5.1/manual.html#pdf-collectgarbage

wxLua already does this at startup to make it a little more frequent:

        // Make the GC a little more aggressive since we push void* data
        // that may be quite large. The upshot is that Lua runs faster.
        // Empirically found by timing: "for i = 1, 1E6 do local p =
wx.wxPoint() end"
        lua_gc(L, LUA_GCSETPAUSE, 120);
        lua_gc(L, LUA_GCSETSTEPMUL, 400);

Regards,
    John


On Fri, Nov 14, 2008 at 12:28 PM, John Labenski <[EMAIL PROTECTED]> wrote:
> 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