title, aliases, tags, related
| title |
aliases |
tags |
related |
| Garbage Collection |
|
|
|
Garbage Collection
OCAS uses mark-and-sweep garbage collection to reclaim storage from nodes that are no longer referenced.
Algorithm
- Roots — all Variable values are roots
- Mark — from each root, recursively
walk() the DAG via Schema edges, marking every reachable node and its schema
- Schema chain preservation — walk each reachable node's type chain upward to preserve the meta-schema hierarchy
- Bootstrap preservation — self-referencing nodes (where
type === hash) are always kept alive
- Sweep — delete all unmarked nodes
Key Properties
- Global — GC operates on the entire Store, not scoped to any variable prefix. Cross-reference between variables is valid and expected
- Schema-aware — the type (schema) of every reachable node is also marked as reachable, preventing orphaned schemas
- Safe — bootstrap nodes (the self-referencing meta-schema) are unconditionally preserved, so GC can never break the store's foundation
- Deterministic — same store state always produces the same GC result
What Stays Alive
A node survives GC if any of the following is true:
- A Variable points to it directly
- It is reachable via
ocas_ref edges from a variable's value
- It is the schema (type) of any reachable node
- It is a self-referencing Bootstrap node