x-lang

← Index

x/sys/gc

Garbage collection control: collect/count/limit! and the mark/free/root hooks, on the Heap class.

GC control homed on the Heap class; ns heap is de-registered – no bare names.

Class 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:

Returns: 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:

Returns: ANY — nil

(Heap free-hook! f)

Install a GC free hook for type-specific cleanup.

Parameters:

Returns: ANY — nil

(Heap mark-root! obj)

Register an object as a GC root: it and everything it references survive collection.

Parameters:

Returns: ANY — nil

(Heap pin! obj)

Pin an object with the system flag so the sweeper never frees it.

Parameters:

Returns: ANY — nil