MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / genstep

Function genstep

lib/lua/src/lgc.c:1442–1467  ·  view source on GitHub ↗

** 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

Source from the content-addressed store, hash-verified

1440** in that case, do a minor collection.
1441*/
1442static void genstep (lua_State *L, global_State *g) {
1443 if (g->lastatomic != 0) /* last collection was a bad one? */
1444 stepgenfull(L, g); /* do a full step */
1445 else {
1446 lu_mem majorbase = g->GCestimate; /* memory after last major collection */
1447 lu_mem majorinc = (majorbase / 100) * getgcparam(g->genmajormul);
1448 if (g->GCdebt > 0 && gettotalbytes(g) > majorbase + majorinc) {
1449 lu_mem numobjs = fullgen(L, g); /* do a major collection */
1450 if (gettotalbytes(g) < majorbase + (majorinc / 2)) {
1451 /* collected at least half of memory growth since last major
1452 collection; keep doing minor collections. */
1453 lua_assert(g->lastatomic == 0);
1454 }
1455 else { /* bad collection */
1456 g->lastatomic = numobjs; /* signal that last collection was bad */
1457 setpause(g); /* do a long wait for next (major) collection */
1458 }
1459 }
1460 else { /* regular case; do a minor collection */
1461 youngcollection(L, g);
1462 setminordebt(g);
1463 g->GCestimate = majorbase; /* preserve base value */
1464 }
1465 }
1466 lua_assert(isdecGCmodegen(g));
1467}
1468
1469/* }====================================================== */
1470

Callers 1

luaC_stepFunction · 0.85

Calls 5

stepgenfullFunction · 0.85
fullgenFunction · 0.85
setpauseFunction · 0.85
youngcollectionFunction · 0.85
setminordebtFunction · 0.85

Tested by

no test coverage detected