On 6/18/06, Steve Kieu <[EMAIL PROTECTED]> wrote: > I am trying to find the reason why my apps is so unstable in win32 and found > which could be a bug, not sure it is in wxLua or lua or even wxWidgets. I > will test with pure wxWidgets to see and post here later on.
I believe it is a problem with the garbage collector of 5.1. I cannot seem to find a way to force it to do a GC on "dead" locals. For example for i = 1, 10 do local p = wx.wxPen(wx.wxColour(0,0,0), 1, wx.wxSOLID) --use pen somehow... p:Delete() -- !!!! end If you don't do p:Destroy() you get 10 pens and 10 colours! If you keep going you'll kill any non NT MSWindows system and after ~5000 or so will start to cause redrawing problems in NT (even XP) systems. This means that you need to do local c = wx.wxColour(1,2,3) local p = = wx.wxPen(c, 1, wx.wxSOLID) -- use p somehow p:Delete() c:Delete() Use the wxLuaEdit program, you need wxStEdit from wxCode.sf.net, and run your program and click on "Output" window and use the menu item wxLua->Show Stack. Under the "Tracked Items" you will get a list of the counts of the different wxWidgets structures that wxLua is tracking and waiting to delete. Like I said, I have tried to force the GC to run, but it doesn't do anything. I'll try to find some time later this week to look at it. I think that it has something to do with lua thinking that these structures are just void* and are small. I wonder if there's a way to give a hint to lua about the size and therefore the need to do a GC on them. > I have such simple script to test > > f=wx.wxFrame(wx.wxNull, -1, "Test") > b=wx.wxButton(f, -1, "Test") > > f:ConnectEvent(-1, wx.wxEVT_COMMAND_BUTTON_CLICKED, function (event) > local d=wx.wxDialog(f,-1,"Test") > d:ShowModal(true) d:Destroy() -- ALWAYS DO THIS > end) > f:Show(true) Just explicitly Destroy() it. I believe that you have always have needed to do this. > Now I click the buton ; show the dialog and close the dialog, Run taskmgr > in win32 to see the memory usage is slowly insreasing after each time and > never reduced. Until the memory usesage is about 20Mb the application > crashed,. Sometimes it freezes, need to kill it. > If you have much memory then it takes much longer to crash it, it seems the > problem is related to the garbage collector in lua when it tries to clean up > the grabage. This is serious problem ; happen both with version 2.6.2.0 I > will test the snapshot tonight and see. Hopefully a solution can be found, sorry, but it'll have to be later this week for me. Regards, John Labenski _______________________________________________ Wxlua-users mailing list Wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users