Garbage collection control: collect/count/limit! and the mark/free/root hooks, on the Heap class.
GC control homed on the Heap class; ns
heapis de-registered – no bare names.
Heap(Heap collect)Run a full, atomic garbage collection (mark + sweep in one C call).
Returns: ANY — nil (count freed objects via (Heap count) deltas; see x/tool/profile)
(Heap count)Count live heap objects.
Returns: INT — Number of objects on the heap
(Heap limit! n)Set the heap-object ceiling: a collection that cannot get under it errors.
Parameters:
INT — Heap-object ceiling; 0 disablesReturns: ANY — nil
(Heap mark)LOW-LEVEL: run only the mark phase. Pair with sweep atomically – prefer (Heap collect).
Returns: ANY — nil
(Heap sweep)LOW-LEVEL: run only the sweep phase. Pair with mark atomically – prefer (Heap collect).
Returns: ANY — nil
(Heap mark-hook! f)Install a GC mark hook (e.g. to mark objects only C can reach).
Parameters:
CALLABLE — Hook: called during the mark phaseReturns: ANY — nil
(Heap free-hook! f)Install a GC free hook for type-specific cleanup.
Parameters:
CALLABLE — Hook: called as objects are freedReturns: ANY — nil
(Heap mark-root! obj)Register an object as a GC root: it and everything it references survive collection.
Parameters:
ANY — Object to pin as a GC rootReturns: ANY — nil
(Heap pin! obj)Pin an object with the system flag so the sweeper never frees it.
Parameters:
ANY — Object to mark as a system objectReturns: ANY — nil