Garbage collection
- Lua uses garbage collection.
- It uses a mark and sweep garbage collector
- The collector as of version 5.0 runs interleaved with the interpreter
Mark and Sweep
Mark and sweep performs garbage collection is three stages: mark, cleaning, and sweep Mark - all reachable objects are marked as alive Cleaning - Looks at all objects with a finalizer looking for non-marked objects. These are put into a separate list to be handled. It also looks at all weak tables and eliminates any entries that are not marked. Weak tables are discussed below Sweep - all objects are sweeped and those not marked are collected. Lua also calls the finalizers of any objects put in the finalizer list ```