Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9f85ece

Browse files
committed
dispose luafunction ASAP
1 parent3bae8b3 commit9f85ece

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

‎Assets/Plugins/Slua_Managed/LuaState.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,10 @@ public object this[int index]
368368

369369
publicobjectinvoke(stringfunc,paramsobject[]args)
370370
{
371-
LuaFunctionf=(LuaFunction)this[func];
372-
if(f!=null)
373-
{
374-
returnf.call(args);
371+
using(LuaFunctionf=(LuaFunction)this[func]){
372+
if(f!=null){
373+
returnf.call(args);
374+
}
375375
}
376376
thrownewException(string.Format("Can't find {0} function",func));
377377
}

‎Assets/Plugins/Slua_Managed/LuaSvr.cs‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,10 @@ public object start(string main)
264264
if(main!=null)
265265
{
266266
luaState.doFile(main);
267-
LuaFunctionfunc=(LuaFunction)luaState["main"];
268-
if(func!=null)
269-
returnfunc.call();
267+
using(LuaFunctionfunc=(LuaFunction)luaState["main"]){
268+
if(func!=null)
269+
returnfunc.call();
270+
}
270271
}
271272
returnnull;
272273
}

‎Assets/Slua/Editor/CustomEditor.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public override void OnInspectorGUI()
3737
if(GUILayout.Button("Lua GC"))
3838
{
3939
LuaDLL.lua_gc(myTarget.state.L,LuaGCOptions.LUA_GCCOLLECT,0);
40+
System.GC.Collect();
4041
}
4142
}
4243
}

‎Assets/Slua/Editor/LuaConsole.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,18 +443,21 @@ void DoCommand(string str)
443443
return;
444444
LuaFunctionf=luaState.doString(COMMON_DEFINE+"return printExpr","LuaConsole")asLuaFunction;
445445
f.call(tail);
446+
f.Dispose();
446447
}
447448
elseif(cmd=="dir")
448449
{
449450
if(tail=="")
450451
return;
451452
LuaFunctionf=luaState.doString(COMMON_DEFINE+"return dirExpr","LuaConsole")asLuaFunction;
452453
f.call(tail);
454+
f.Dispose();
453455
}
454456
else
455457
{
456458
LuaFunctionf=luaState.doString(COMMON_DEFINE+"return compile","LuaConsole")asLuaFunction;
457459
f.call(str);
460+
f.Dispose();
458461
}
459462
}
460463

‎Assets/Slua/example/NewCoroutine.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ void Start () {
1717
svr.init(null,()=>
1818
{
1919
varfunc=(LuaFunction)svr.start("new_coroutine");
20-
2120
func.call(this);
21+
func.Dispose();
2222
});
2323
}
2424

‎Assets/Slua/example/test/test.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ private void _Calc (LuaState lua, int i)
262262
lua.doString("function calcVP(a,b) return a+b end");
263263
LuaFunctionlf=lua.getFunction("calcVP");
264264
lf.call(i,20);
265+
lf.Dispose();
265266
}
266267

267268

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp