[−][src]Trait mruby::gc::MrbGarbageCollection
Garbage collection primitives for an mruby interpreter.
Required methods
fn create_arena_savepoint(&self) -> ArenaIndex
Create a savepoint in the GC arena which will allow mruby to deallocate all of the objects created via the C API.
Normally objects created via the C API are marked as permanently alive
("white" GC color) with a call to
mrb_gc_protect
.
The returned ArenaIndex
implements Drop
, so it is sufficient to
let it go out of scope to ensure objects are eventually collected.
fn live_object_count(&self) -> i32
Retrieve the number of live objects on the interpreter heap.
A live object is reachable via top self, the stack, or the arena.
fn incremental_gc(&self)
Perform an incremental garbage collection.
An incremental GC is less computationally expensive than a full GC, but does not guarantee that all dead objects will be reaped. You may wish to use an incremental GC if you are operating with an interpreter in a loop.
fn full_gc(&self)
Perform a full garbage collection.
A full GC guarantees that all dead objects will be reaped, so it is more expensive than an incremental GC. You may wish to use a full GC if you are memory constrained.
fn enable_gc(&self) -> bool
Enable garbage collection.
Returns the prior GC enabled state.
fn disable_gc(&self) -> bool
Disable garbage collection.
Returns the prior GC enabled state.