The std.gc module provides control over the ProXPL garbage collector and access to memory statistics.
Note: This module is part of the standard library but interacts directly with the runtime's memory management system.
Force a garbage collection cycle immediately.
Signature
collect() -> intReturns
int: The number of bytes freed during this collection cycle.
Example
use std.gc;
// Force cleanup
let freed = gc.collect();
print("Freed bytes: " + to_string(freed));Retrieve current memory statistics from the garbage collector.
Signature
stats() -> listReturns
list: A list containing[bytesAllocated, nextGCThreshold].bytesAllocated(index 0): Total bytes currently allocated by the VM.nextGCThreshold(index 1): The allocation threshold that will trigger the next automatic GC.
Example
use std.gc;
let stats = gc.stats();
print("Current Usage: " + to_string(stats[0]) + " bytes");
print("Next GC at: " + to_string(stats[1]) + " bytes");Quickly check current memory usage.
Signature
usage() -> intReturns
int: Total bytes currently allocated.
Example
use std.gc;
print("Memory: " + to_string(gc.usage()));