lua: fix memory leak causing crash after a few dozen script loads/resets
This commit is contained in:
parent
e0985465b6
commit
8bc067cbbe
|
@ -49,6 +49,7 @@
|
|||
public void Stop()
|
||||
{
|
||||
State = RunState.Disabled;
|
||||
Thread.GetTable("keepalives")[Thread] = null;
|
||||
Thread = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue