saberGC is a prototype of garbage collection system in C++.
- Naïve mark-and-sweep and exact garbage collection.
shared_ptr
/unique_ptr
-like interface.- Custom
memory_resource
support. - Not a singleton and no global/static variables.
- There can be multiple GC instances if necessary.
- C++17 (clang, MSVC, gcc, etc.)
- Uses
memory_resource
,polymorphic_allocator
,variant
,[[maybe_unused]]
, ...
- Uses
struct Foo
{
saber::GC::Object<Foo> foo_;
};
int main()
{
saber::GC gc;
auto foo = gc.new_object<Foo>();
foo->foo_ = foo; // It's a cyclic reference, but no problem.
return 0;
} // saber::GC collects garbages implicitly when destroyed.
-
Array type construction support. -
Exception safety support. -
Copy construction/assignment support fromObject<Derived>
. - Benchmarking.
- Move semantics support. (But no plans as of now)