diff options
Diffstat (limited to 'lgc.c')
-rw-r--r-- | lgc.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.221 2017/04/11 19:00:27 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.222 2017/04/12 18:01:40 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -1158,6 +1158,7 @@ static void entergen (lua_State *L, global_State *g) { | |||
1158 | 1158 | ||
1159 | finishgencycle(L, g); | 1159 | finishgencycle(L, g); |
1160 | g->gckind = KGC_GEN; | 1160 | g->gckind = KGC_GEN; |
1161 | g->GCestimate = gettotalbytes(g); /* base for memory control */ | ||
1161 | } | 1162 | } |
1162 | 1163 | ||
1163 | 1164 | ||
@@ -1205,10 +1206,17 @@ static void fullgen (lua_State *L, global_State *g) { | |||
1205 | ** collection. (We still has to implement the full control.) | 1206 | ** collection. (We still has to implement the full control.) |
1206 | */ | 1207 | */ |
1207 | static void genstep (lua_State *L, global_State *g) { | 1208 | static void genstep (lua_State *L, global_State *g) { |
1208 | lu_mem mem; | 1209 | lu_mem majorbase = g->GCestimate; |
1209 | youngcollection(L, g); | 1210 | lua_checkmemory(L); |
1210 | mem = gettotalbytes(g); | 1211 | if (gettotalbytes(g) > (majorbase / 100) * (100 + g->genmajormul)) |
1211 | luaE_setdebt(g, -((mem / 100) * 20)); | 1212 | fullgen(L, g); |
1213 | else { | ||
1214 | lu_mem mem; | ||
1215 | youngcollection(L, g); | ||
1216 | mem = gettotalbytes(g); | ||
1217 | luaE_setdebt(g, -((mem / 100) * g->genminormul)); | ||
1218 | g->GCestimate = mem; | ||
1219 | } | ||
1212 | lua_checkmemory(L); | 1220 | lua_checkmemory(L); |
1213 | } | 1221 | } |
1214 | 1222 | ||