lua: fix memory leak causing crash after a few dozen script loads/resets

This commit is contained in:
zeromus 2017-05-10 01:58:12 -05:00
parent e0985465b6
commit 8bc067cbbe
2 changed files with 5 additions and 1 deletions

View File

@ -49,6 +49,7 @@
public void Stop()
{
State = RunState.Disabled;
Thread.GetTable("keepalives")[Thread] = null;
Thread = null;
}

View File

@ -23,6 +23,7 @@ namespace BizHawk.Client.EmuHawk
public EmuLuaLibrary()
{
Docs = new LuaDocumentation();
_lua["keepalives"] = _lua.NewTable();
}
private FormsLuaLibrary FormsLibrary
@ -172,14 +173,16 @@ namespace BizHawk.Client.EmuHawk
var content = File.ReadAllText(file);
var main = lua.LoadString(content, "main");
lua.Push(main); // push main function on to stack for subsequent resuming
_lua.GetTable("keepalives")[lua] = 1;
_lua.Pop();
return lua;
}
public void ExecuteString(string command)
{
_currThread = _lua.NewThread();
_currThread.DoString(command);
_lua.Pop();
}
public ResumeResult ResumeScript(Lua script)