change in the way 'collectgarbage("step", size)' interprets 'size'

(mimicking the way the GC itself behaves when Lua allocates 'size'
Kbytes)
This commit is contained in:
Roberto Ierusalimschy
2014-02-14 14:43:14 -02:00
parent 0b04c561f5
commit 1cce3e6842
3 changed files with 23 additions and 24 deletions

22
lgc.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lgc.c,v 2.172 2014/02/13 14:46:38 roberto Exp roberto $
** $Id: lgc.c,v 2.173 2014/02/13 17:25:20 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@@ -1087,11 +1087,15 @@ static l_mem getdebt (global_State *g) {
}
/*
** performs a basic GC step
** performs a basic GC step when collector is running
*/
void luaC_forcestep (lua_State *L) {
void luaC_step (lua_State *L) {
global_State *g = G(L);
l_mem debt = getdebt(g);
if (!g->gcrunning) { /* not running? */
luaE_setdebt(g, -GCSTEPSIZE * 10); /* avoid being called too often */
return;
}
do {
if (g->gcstate == GCScallfin && g->tobefnz) {
unsigned int n = runafewfinalizers(L);
@@ -1112,18 +1116,6 @@ void luaC_forcestep (lua_State *L) {
}
/*
** performs a basic GC step when collector is running
*/
void luaC_step (lua_State *L) {
if (!G(L)->gcrunning)
luaE_setdebt(G(L), -GCSTEPSIZE); /* avoid being called too often */
else
luaC_forcestep(L);
}
/*
** performs a full GC cycle; if "isemergency", does not call
** finalizers (which could change stack positions)