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.

------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
wxlua-users mailing list
wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to