Skip to content

Commit 0146b91

Browse files
committed
Added hack to make lua GC more aggressive when using OOP Matrix & Vector
1 parent 840b676 commit 0146b91

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/lapi.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ LUA_API int lua_pushthread (lua_State *L) {
551551
}
552552

553553

554-
555554
/*
556555
** get functions (Lua -> stack)
557556
*/
@@ -898,7 +897,7 @@ LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
898897
}
899898

900899

901-
#ifdef WITH_STRING_DUMP
900+
#ifdef WITH_STRING_DUMP
902901
LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
903902
int status;
904903
TValue *o;
@@ -1128,3 +1127,10 @@ LUA_API int luaX_is_apicheck_enabled()
11281127
return 0;
11291128
}
11301129
#endif
1130+
1131+
// MTA addition to tweak GC behaviour
1132+
LUA_API void lua_addtotalbytes(lua_State *L, int n)
1133+
{
1134+
global_State *g = G(L);
1135+
g->totalbytes += n;
1136+
}

src/lua.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ LUA_API void (lua_pushboolean) (lua_State *L, int b);
186186
LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);
187187
LUA_API int (lua_pushthread) (lua_State *L);
188188

189-
190189
/*
191190
** get functions (Lua -> stack)
192191
*/
@@ -357,6 +356,7 @@ LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);
357356
LUA_API lua_Hook lua_gethook (lua_State *L);
358357
LUA_API int lua_gethookmask (lua_State *L);
359358
LUA_API int lua_gethookcount (lua_State *L);
359+
LUA_API void lua_addtotalbytes(lua_State *L, int n);
360360

361361

362362
struct lua_Debug {

0 commit comments

Comments
 (0)