diff options
| -rw-r--r-- | lgc.c | 23 |
1 files changed, 11 insertions, 12 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.c,v 2.168 2013/12/13 15:42:08 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.169 2014/02/11 12:18:12 roberto Exp roberto $ |
| 3 | ** Garbage Collector | 3 | ** Garbage Collector |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -1208,24 +1208,23 @@ void luaC_forcestep (lua_State *L) { | |||
| 1208 | 1208 | ||
| 1209 | 1209 | ||
| 1210 | /* | 1210 | /* |
| 1211 | ** performs a basic GC step only if collector is running | 1211 | ** performs a basic GC step or a local collection when collector is running |
| 1212 | */ | 1212 | */ |
| 1213 | void luaC_step (lua_State *L) { | 1213 | void luaC_step (lua_State *L) { |
| 1214 | global_State *g = G(L); | 1214 | global_State *g = G(L); |
| 1215 | if (g->gcrunning) { | 1215 | if (!g->gcrunning) |
| 1216 | if (g->gcstate != GCSpause) { | 1216 | luaE_setdebt(g, -GCSTEPSIZE); /* avoid being called too often */ |
| 1217 | luaC_forcestep(L); | 1217 | else { |
| 1218 | } | 1218 | if (g->gcstate != GCSpause) /* in the middle of a cycle? */ |
| 1219 | luaC_forcestep(L); /* continue it */ | ||
| 1219 | else { | 1220 | else { |
| 1220 | luaC_localcollection(L); | 1221 | luaC_localcollection(L); /* try a local collection */ |
| 1221 | if (gettotalbytes(g) > g->GCthreshold) { | 1222 | if (gettotalbytes(g) <= g->GCthreshold) /* enough? */ |
| 1222 | luaC_forcestep(L); /* restart collection */ | ||
| 1223 | } | ||
| 1224 | else | ||
| 1225 | luaE_setdebt(g, -g->gclocalpause); | 1223 | luaE_setdebt(g, -g->gclocalpause); |
| 1224 | else /* local collection did not collect enough memory */ | ||
| 1225 | luaC_forcestep(L); /* start a full collection */ | ||
| 1226 | } | 1226 | } |
| 1227 | } | 1227 | } |
| 1228 | else luaE_setdebt(g, -GCSTEPSIZE); /* avoid being called too often */ | ||
| 1229 | } | 1228 | } |
| 1230 | 1229 | ||
| 1231 | 1230 | ||
