This is a proof-of-concept garbage collector for the Odin language using the Boehm-Demers-Weiser conservative C/C++ Garbage Collector.
It currently requires Linux, and a copy of libgc, which is packaged by most distributions.
import gc "path/to/odin-gc`
main :: proc() {
context = gc.init_context()
// Do useful things:
//
// - You *can* use `free` and `delete`, if you really want to, but
// why bother? Embrace the lazy.
// - Do NOT use:
// - `core:dynlib.load_library`, use `gc.load_library` instead.
// - `core:thread`
// - Avoid:
// - `base:runtime/heap_allocator`
// - `core:mem/virtual`
}
- It is a stop-the-world mark-and-sweep GC.
GC_init
is used instead ofGC_INIT
.gc.load_library
must be used instead ofcore:dynlib/load_library
core:thread
may appear to work, but it likely is broken.
- Add support for controlling GC behavior.
- Add an allocator for "atomic" memory.
- Add an allocator for "uncollectable" memory.
- Work on supporting the things that are broken.