** 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
| 1412 | ** in that case, do a minor collection. |
| 1413 | */ |
| 1414 | static void genstep (lua_State *L, global_State *g) { |
| 1415 | if (g->lastatomic != 0) /* last collection was a bad one? */ |
| 1416 | stepgenfull(L, g); /* do a full step */ |
| 1417 | else { |
| 1418 | lu_mem majorbase = g->GCestimate; /* memory after last major collection */ |
| 1419 | lu_mem majorinc = (majorbase / 100) * getgcparam(g->genmajormul); |
| 1420 | if (g->GCdebt > 0 && gettotalbytes(g) > majorbase + majorinc) { |
| 1421 | lu_mem numobjs = fullgen(L, g); /* do a major collection */ |
| 1422 | if (gettotalbytes(g) < majorbase + (majorinc / 2)) { |
| 1423 | /* collected at least half of memory growth since last major |
| 1424 | collection; keep doing minor collections */ |
| 1425 | setminordebt(g); |
| 1426 | } |
| 1427 | else { /* bad collection */ |
| 1428 | g->lastatomic = numobjs; /* signal that last collection was bad */ |
| 1429 | setpause(g); /* do a long wait for next (major) collection */ |
| 1430 | } |
| 1431 | } |
| 1432 | else { /* regular case; do a minor collection */ |
| 1433 | youngcollection(L, g); |
| 1434 | setminordebt(g); |
| 1435 | g->GCestimate = majorbase; /* preserve base value */ |
| 1436 | } |
| 1437 | } |
| 1438 | lua_assert(isdecGCmodegen(g)); |
| 1439 | } |
| 1440 | |
| 1441 | /* }====================================================== */ |
| 1442 |
no test coverage detected