major collections in generational mode
This commit is contained in:
20
lgc.c
20
lgc.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lgc.c,v 2.71 2010/03/24 15:51:10 roberto Exp roberto $
|
||||
** $Id: lgc.c,v 2.72 2010/03/25 13:06:36 roberto Exp roberto $
|
||||
** Garbage Collector
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@@ -835,11 +835,19 @@ static int prev = 0;
|
||||
global_State *g = G(L);
|
||||
int a = g->totalbytes;
|
||||
lua_assert(g->gcstate == GCSpropagate);
|
||||
luaC_runtilstate(L, bitmask(GCSpause));
|
||||
g->gcstate = GCSpropagate; /* do not run 'markroot' */
|
||||
if (g->lastmajormem == 0) { /* signal for another major collection? */
|
||||
luaC_fullgc(L, 0); /* perform a full regular collection */
|
||||
g->lastmajormem = g->totalbytes; /* update control */
|
||||
}
|
||||
else {
|
||||
luaC_runtilstate(L, bitmask(GCSpause));
|
||||
g->gcstate = GCSpropagate; /* do not run 'markroot' */
|
||||
if (g->totalbytes > g->lastmajormem/100 * g->gcpause)
|
||||
g->lastmajormem = 0; /* signal for a major collection */
|
||||
}
|
||||
g->GCthreshold = (g->totalbytes/100) * g->gcpause;
|
||||
/*printf("count: %d old: %d new: %d dif: %d\n", c++, a, g->totalbytes,
|
||||
g->totalbytes - prev);*/
|
||||
/*printf("count: %d old: %d new: %d dif: %d lim: %d threshold: %d\n",
|
||||
c++, a, g->totalbytes, g->totalbytes - prev, g->lastmajormem, g->GCthreshold);*/
|
||||
prev = g->totalbytes;
|
||||
}
|
||||
|
||||
@@ -890,7 +898,7 @@ void luaC_fullgc (lua_State *L, int isemergency) {
|
||||
if (!isemergency) /* do not run finalizers during emergency GC */
|
||||
luaC_runtilstate(L, bitmask(GCSpause));
|
||||
if (origkind == KGC_GEN) { /* generational mode? */
|
||||
g->gckind = GCSpause; /* collector must be always in... */
|
||||
g->gcstate = GCSpause; /* collector must be always in... */
|
||||
luaC_runtilstate(L, bitmask(GCSpropagate)); /* ...propagate phase */
|
||||
}
|
||||
g->GCthreshold = (g->totalbytes/100) * g->gcpause;
|
||||
|
||||
Reference in New Issue
Block a user