lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> On 15 August 2018 at 00:55, Hisham <h@hisham.hm> wrote:
> > Is a major collection in the generational GC comparable to a full
> > collection as triggered by collectgarbage()? I thought it would be
> > more like a regular collection from the incremental GC (with the minor
> > collections being faster than those).
> 
> 
> in my mental model (plz correct!)  a collection "step" is comparable
> in both GC designs, the main difference is when they consider that
> they've done enough steps and switch to the next phase.  in the "old"
> GC it's when the whole tree has been traversed, while in generational
> GC it's when the next objects are "too old", unless this happened to
> be a major cycle, then it keeps on as previously.

The generational collector is not incremental. It does not have "steps";
it always performs a complete collection each time it is invoked. What
changes is what objects it traverses and sweeps (only new objects in
minor collections and all of them in major collections).

A major collection in generational mode is the same as a full collection
triggered by collectgarbage(). This is also the same as a "regular"
collection from the incremental GC, except that in incremental mode this
"regular" (or "full") collection is done incrementally, interleaved with
program execution.

Usually, a minor collection is much faster than a full ("regular")
collection, but slower than a single step from the incremental collector.


> that still leaves the question: would `collectgarbage('collect')`
> always do a major collection, or just a full cycle of whatever size is
> currently scheduled?

It always performs a full collection, which is equivalent to enough steps
in incremental mode or a major collection in generational mode.

Moreover, an emergency collection can happen in any mode, whenever an
allocation fails. It is equivalent to a full collection, except that
it does not run finalizers. (They are queued to be run in the next
opportunity.)

-- Roberto