gcmodule
Garbage collection inspired by CPython's implementation.
This library provides a type Cc<T>
. It provides shared reference-counting pointer, similar to stdlib Rc<T>
. Unlike Rc
, reference cycles in Cc
can be collected.
Example
use ;
use RefCell;
type List = ;
let a: List = Default default;
let b: List = Default default;
a.borrow_mut.push;
b.borrow_mut.push; // Form a cycle.
drop;
drop; // Internal values are not dropped due to the cycle.
collect_thread_cycles; // Internal values are dropped.
Similar Projects
bacon-rajan-cc v0.3
- Both are reference count, with cyclic garbage collection.
- Both are single-threaded, and stop-the-world.
- Main APIs like
Cc<T>
andTrace
are similar, or even compatible. gcmodule
is conceptually simpler. There is no need for the "colors" concept.gcmodule
does not require extra space for bookkeeping, if all objects are freed by reference counting. See this commit message for some details.