** Does a major collection after last collection was a "bad collection". ** ** When the program is building a big structure, it allocates lots of ** memory but generates very little garbage. In those scenarios, ** the generational mode just wastes time doing small collections, and ** major collections are frequently what we call a "bad collection", a ** collection that frees too few objects. To av
| 1272 | ** ('g->lastatomic != 0' also means that the last collection was bad.) |
| 1273 | */ |
| 1274 | static void stepgenfull (lua_State *L, global_State *g) { |
| 1275 | lu_mem newatomic; /* count of traversed objects */ |
| 1276 | lu_mem lastatomic = g->lastatomic; /* count from last collection */ |
| 1277 | if (g->gckind == KGC_GEN) /* still in generational mode? */ |
| 1278 | enterinc(g); /* enter incremental mode */ |
| 1279 | luaC_runtilstate(L, bitmask(GCSpropagate)); /* start new cycle */ |
| 1280 | newatomic = atomic(L); /* mark everybody */ |
| 1281 | if (newatomic < lastatomic + (lastatomic >> 3)) { /* good collection? */ |
| 1282 | atomic2gen(L, g); /* return to generational mode */ |
| 1283 | setminordebt(g); |
| 1284 | } |
| 1285 | else { /* another bad collection; stay in incremental mode */ |
| 1286 | g->GCestimate = gettotalbytes(g); /* first estimate */; |
| 1287 | entersweep(L); |
| 1288 | luaC_runtilstate(L, bitmask(GCSpause)); /* finish collection */ |
| 1289 | setpause(g); |
| 1290 | g->lastatomic = newatomic; |
| 1291 | } |
| 1292 | } |
| 1293 | |
| 1294 | |
| 1295 | /* |
no test coverage detected