Collector

← Reference
Io

Thin Io-facing wrapper around the underlying C Collector (see basekit/source/Collector.c). There is no dedicated IoCollector struct — the proto is just an IoObject carrying a method table; every method forwards to Collector_* on IOSTATE->collector. Because of that, the file has no tag/newTag/rawClone/free/mark functions: lifecycle of the collector itself is owned by IoState. The Io-level methods exposed here (collect, setMarksPerAlloc, allObjects, dirtyObjects, etc.) let scripts tune and inspect the incremental tri-color mark-sweep at runtime. COLLECTOR_FOREACH iterates every live marker and is used by the introspection methods.

IoCollector_check(self, locals, m)

Runs the collector's internal self-check (mark-color invariants, free list consistency). Available for test suites that want a hard abort on corruption rather than waiting for a sweep to stumble into it.

IoCollector_checkMemory(self, locals, m)

Debug aid: runs Collector_check and then walks every live object invoking IoObject_rawCheckMemory on it, which touches the IoObjectData struct to trip an access violation if any object's memory is corrupt. Intentionally has no /doc comment — this is an unadvertised debugging entry point.

IoCollector_checkObjectPointers(self, locals, m)

Debug aid that validates every object pointer tracked by the collector. Used alongside checkMemory when hunting double-frees or stale pointer regressions in primitive free functions.

IoCollector_proto(state)

Builds the Collector singleton: a plain IoObject with a "type" slot of "Collector" and a method table that forwards to the underlying C Collector. Called once during IoState init. Unlike other protos, there is no tag of its own — the object behaves as an ordinary Object and the collector itself is owned by state->collector.

IoCollector_setSafeModeOn(self, locals, m)

Toggles the collector's "safe mode" — a conservative mode used during bootstrap / shutdown when object graphs may be in a transient state. Undocumented at the Io level on purpose; scripts should not normally touch it.