0% found this document useful (0 votes)
3 views6 pages

Lua Garbage Collection Techniques

Lua's garbage collection (GC) until version 5.0 faced long pauses during cycles, but version 5.1 introduced an incremental collector that interleaves GC with program execution. The tri-color collector categorizes objects into three states: white, gray, and black, with specific rules governing their transitions. Collection continues until no gray objects remain, ensuring efficient memory management.

Uploaded by

xyxmnff
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

Lua Garbage Collection Techniques

Lua's garbage collection (GC) until version 5.0 faced long pauses during cycles, but version 5.1 introduced an incremental collector that interleaves GC with program execution. The tri-color collector categorizes objects into three states: white, gray, and black, with specific rules governing their transitions. Collection continues until no gray objects remain, ensuring efficient memory management.

Uploaded by

xyxmnff
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Lua GC until Version 5.

0
● Main drawback of Mark & Sweep: pauses in the
program execution during a GC cycle can be
very long.
In version 5.1, Lua got an incremental
collector. An incremental collector
interleaves the execution of the collector
with the main program.
The Mutator
● From the garbage collector's point of view, the
program is just some nuisance changing the
data it is trying to collect: the mutator!
Tri-color Collector
● Each object is in one of three states: white,
gray, or black.
● Non-visited objects are marked white.
● Visited but not-traversed objects are marked
gray.
● Traversed objects are marked black.
Invariants
● Objects in the root set are gray or black.
● A black object cannot point to a white object.
● Gray objects define the boundary between the
black objects and the white objects.
● Collection advances by traversing gray objects,
turning them black.
– which may create new gray objects
● Collection ends when there are no more gray
objects.

You might also like