Hi John,

Any update on a fix for this leak? It's easy to reproduce and would be
great if this could be fixed, but I can't figure out what resources
are not being collected...

One more detail on this; it appears to leak even on `ctrl[{}]` call,
which is the shortest branch of all the checks in
`wxlua_wxLuaBindClass__index` method. There is not much going on
before wxlua_error call, but since it's leaking on some other errors
too (for example, on wrong attribute types), I suspect it has
something to do with the error handling. I also tested with both Lua
5.1 and LuaJIT and the results are the same, so it seems like it's
wxlua-related.

Paul.

On Thu, Sep 3, 2015 at 9:13 AM, Paul K <paulclin...@yahoo.com> wrote:
> Hi John,
>
> I noticed that there is a memory leak when wxlua script checks for
> non-existing properties inside pcall. For example, the following
> script leaks about 5M of memory on Windows:
>
> require "wx"
> local ctrl = wx.wxTextCtrl()
> for _ = 1, 10000 do pcall(function() return ctrl.foo end) end
> io.read()
>
> (if you are checking in TaskManager, you need to look for Lua process
> under "background processes" section).
>
> Adding "collectgarbage" doesn't help, so the leak seems to be in the
> memory allocated outside of Lua.
> "pcall" is needed to avoid "wxLua: Unable to call an unknown method
> 'foo' on a 'wxTextCtrl' type." If the check is for the existing
> property, then there is no leak. If I cause the error in "pcall" in
> some other way, there is no leak either. I don't think pcall is
> causing the issue; there is probably something wrong with the cleanup
> after the error.
>
> Do you have any idea on what may be causing this? I wouldn't worry
> about it too much, but there is no way to check if the property exists
> without wrapping the check into a "pcall" and leaking 0.5k per check
> is a bit too much.
>
> As a side note, I'd prefer "obj.foo" check to return "nil" instead of
> failing with an error. This would be a behavior consistent with how
> fields behave for tables in Lua.
>
> Paul.

------------------------------------------------------------------------------
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to