** Does a generational "step". ** Usually, this means doing a minor collection and setting the debt to ** make another collection when memory grows 'genminormul'% larger. ** ** However, there are exceptions. If memory grows 'genmajormul'% ** larger than it was at the end of the last major collection (kept ** in 'g->GCestimate'), the function does a major collection. At the ** end, it checks wheth
| 1312 | ** in that case, do a minor collection. |
| 1313 | */ |
| 1314 | static void genstep (lua_State *L, global_State *g) { |
| 1315 | if (g->lastatomic != 0) /* last collection was a bad one? */ |
| 1316 | stepgenfull(L, g); /* do a full step */ |
| 1317 | else { |
| 1318 | lu_mem majorbase = g->GCestimate; /* memory after last major collection */ |
| 1319 | lu_mem majorinc = (majorbase / 100) * getgcparam(g->genmajormul); |
| 1320 | if (g->GCdebt > 0 && gettotalbytes(g) > majorbase + majorinc) { |
| 1321 | lu_mem numobjs = fullgen(L, g); /* do a major collection */ |
| 1322 | if (gettotalbytes(g) < majorbase + (majorinc / 2)) { |
| 1323 | /* collected at least half of memory growth since last major |
| 1324 | collection; keep doing minor collections */ |
| 1325 | setminordebt(g); |
| 1326 | } |
| 1327 | else { /* bad collection */ |
| 1328 | g->lastatomic = numobjs; /* signal that last collection was bad */ |
| 1329 | setpause(g); /* do a long wait for next (major) collection */ |
| 1330 | } |
| 1331 | } |
| 1332 | else { /* regular case; do a minor collection */ |
| 1333 | youngcollection(L, g); |
| 1334 | setminordebt(g); |
| 1335 | g->GCestimate = majorbase; /* preserve base value */ |
| 1336 | } |
| 1337 | } |
| 1338 | lua_assert(isdecGCmodegen(g)); |
| 1339 | } |
| 1340 | |
| 1341 | /* }====================================================== */ |
| 1342 |
no test coverage detected