|
jam 0.0.1
A compacting generational garbage collector for C++26
|
jam is a compacting generational garbage collector for C++26. Build lists, trees or graphs, keep roots, and let the collector reclaim what you can no longer reach. Sharing and cycles are fine. A pointer takes four bytes, and objects need no GC header or intrusive base class.
Tell us where your pointers live and we generate the walk:
Here next is a managed edge; data is just data. The two nodes form a cycle. answer keeps it alive, and collection repairs the links as objects move. Drop the root and the whole cycle becomes collectible.
Manifests compose through embedded records and arrays. You can store SIMD pointer vectors too, or supply a trace hook when the layout depends on a tag. The tracing guide and pointer vector examples pick up from there. A weak_ptr<T> follows movement without keeping its target alive. A `weak_root<T>` does the same from outside the heap and stays valid across collection. Weak associations and finalizers let a live key keep a value alive and schedule a managed cleanup action when the key dies.
There are a few things you have to get right:
You choose when to call collect(). Most calls collect only young objects; periodically one collects both generations. Writes from old objects to young ones are tracked automatically. Collection policy and sizing cover the controls when you need them.
To try it, you'll need Clang 23+, CMake 4.4+ and Ninja on macOS, Linux or Windows. The build guide has the commands. import jam.unqualified; puts the names in scope as above; use import jam; for qualified names.
The topic guides go deeper; the API reference documents the individual operations.
See LICENSE.md for the dual BSD-2-Clause/Apache-2.0 license and individual source notices for retained upstream terms.
Contributions and bug reports are welcome through GitHub. Edward Kmett can also be reached as ekmett on Libera Chat and @kmett on Twitter/X.