small bug in generational control

This commit is contained in:
Roberto Ierusalimschy
2017-04-20 15:24:33 -03:00
parent f748b4bb40
commit c354211744

11
lgc.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lgc.c,v 2.222 2017/04/12 18:01:40 roberto Exp roberto $ ** $Id: lgc.c,v 2.223 2017/04/19 17:02:50 roberto Exp roberto $
** Garbage Collector ** Garbage Collector
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -1207,17 +1207,18 @@ static void fullgen (lua_State *L, global_State *g) {
*/ */
static void genstep (lua_State *L, global_State *g) { static void genstep (lua_State *L, global_State *g) {
lu_mem majorbase = g->GCestimate; lu_mem majorbase = g->GCestimate;
lua_checkmemory(L); //lua_checkmemory(L);
if (gettotalbytes(g) > (majorbase / 100) * (100 + g->genmajormul)) if (gettotalbytes(g) > (majorbase / 100) * (100 + g->genmajormul)) {
fullgen(L, g); fullgen(L, g);
}
else { else {
lu_mem mem; lu_mem mem;
youngcollection(L, g); youngcollection(L, g);
mem = gettotalbytes(g); mem = gettotalbytes(g);
luaE_setdebt(g, -((mem / 100) * g->genminormul)); luaE_setdebt(g, -((mem / 100) * g->genminormul));
g->GCestimate = mem; g->GCestimate = majorbase; /* preserve base value */
} }
lua_checkmemory(L); //lua_checkmemory(L);
} }