aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-24 14:52:18 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-24 14:52:18 -0300
commitf399e6705fab15013ae468049c910577e1a9a5a1 (patch)
treebb5d1e9da12eb1634dacd923633d6b97ff61acac
parent69371c4b84becac09c445aae01d005b49658ef82 (diff)
downloadlua-f399e6705fab15013ae468049c910577e1a9a5a1.tar.gz
lua-f399e6705fab15013ae468049c910577e1a9a5a1.tar.bz2
lua-f399e6705fab15013ae468049c910577e1a9a5a1.zip
ensures that "collectgarbage'step'" in generational mode does a
minor collection
-rw-r--r--lgc.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lgc.c b/lgc.c
index d27ea42b..692326f3 100644
--- a/lgc.c
+++ b/lgc.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lgc.c,v 2.224 2017/04/20 18:24:33 roberto Exp roberto $ 2** $Id: lgc.c,v 2.225 2017/04/24 16:59:26 roberto Exp $
3** Garbage Collector 3** Garbage Collector
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -1202,13 +1202,18 @@ static void fullgen (lua_State *L, global_State *g) {
1202 1202
1203 1203
1204/* 1204/*
1205** Does a generational "step". For now that means a young 1205** Does a generational "step". If memory grows 'genmajormul'% larger
1206** collection. (We still has to implement the full control.) 1206** than last major collection (kept in 'g->GCestimate'), does a major
1207** collection. Otherwise, does a minor collection and set debt to make
1208** another collection when memory grows 'genminormul'% larger.
1209** 'GCdebt <= 0' means an explicity call to GC step with "size" zero;
1210** in that case, always do a minor collection.
1207*/ 1211*/
1208static void genstep (lua_State *L, global_State *g) { 1212static void genstep (lua_State *L, global_State *g) {
1209 lu_mem majorbase = g->GCestimate; 1213 lu_mem majorbase = g->GCestimate;
1210//lua_checkmemory(L); 1214//lua_checkmemory(L);
1211 if (gettotalbytes(g) > (majorbase / 100) * (100 + g->genmajormul)) { 1215 if (g->GCdebt > 0 &&
1216 gettotalbytes(g) > (majorbase / 100) * (100 + g->genmajormul)) {
1212 fullgen(L, g); 1217 fullgen(L, g);
1213 } 1218 }
1214 else { 1219 else {