lua

A copy of the Lua development repository
Log | Files | Refs | README

commit f399e6705fab15013ae468049c910577e1a9a5a1
parent 69371c4b84becac09c445aae01d005b49658ef82
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Mon, 24 Apr 2017 14:51:51 -0300

ensures that "collectgarbage'step'" in generational mode does a
minor collection

Diffstat:
Mlgc.c | 13+++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/lgc.c b/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.224 2017/04/20 18:24:33 roberto Exp roberto $ +** $Id: lgc.c,v 2.225 2017/04/24 16:59:26 roberto Exp $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -1202,13 +1202,18 @@ static void fullgen (lua_State *L, global_State *g) { /* -** Does a generational "step". For now that means a young -** collection. (We still has to implement the full control.) +** Does a generational "step". If memory grows 'genmajormul'% larger +** than last major collection (kept in 'g->GCestimate'), does a major +** collection. Otherwise, does a minor collection and set debt to make +** another collection when memory grows 'genminormul'% larger. +** 'GCdebt <= 0' means an explicity call to GC step with "size" zero; +** in that case, always do a minor collection. */ static void genstep (lua_State *L, global_State *g) { lu_mem majorbase = g->GCestimate; //lua_checkmemory(L); - if (gettotalbytes(g) > (majorbase / 100) * (100 + g->genmajormul)) { + if (g->GCdebt > 0 && + gettotalbytes(g) > (majorbase / 100) * (100 + g->genmajormul)) { fullgen(L, g); } else {