module core.rt.gc

Code Map

module core.rt.gc;


alias AllocDg = void* delegate(TypeInfo, size_t);

//! Stats structs for the GC, may change often so no API/ABI stability.
struct Stats
{
public:
	//! Counters, always available.
	struct Num
	{
	public:
		collections: u64;
		allocs: u64;
		allocBytes: u64;
		arrayAllocs: u64;
		arrayBytes: u64;
		classAllocs: u64;
		classBytes: u64;
		zeroAllocs: u64;
	}

	//! Slots stats, may not be set for all GCs.
	struct Slot
	{
	public:
		//! Memory in large extents.
		memLarge: u64;
		//! Memory cached in slabs.
		memCached: u64;
		//! Memory used in slabs.
		memUsed: u64;
		//! Total memory: used or cached.
		memTotal: u64;
		free: u32[16];
		used: u32[16];
	}


public:
	//! Counters.
	num: Num;
	//! Slots stats.
	slots: Slot;
}

local allocDg: AllocDg;

//! Initialise the GC.
fn vrt_gc_init();
//! Get an instance of the AllocDg delegate.
fn vrt_gc_get_alloc_dg() AllocDg;
//! Perform a collection.
fn vrt_gc_collect();
//! Shutdown the GC, call all destructors, free all memory.
fn vrt_gc_shutdown();
//! Fill out a given Stats struct.
fn vrt_gc_get_stats(stats: Stats) Stats*;
fn vrt_gc_print_stats();
struct Stats

Stats structs for the GC, may change often so no API/ABI stability.

struct Num

Counters, always available.

struct Slot

Slots stats, may not be set for all GCs.

memLarge: u64

Memory in large extents.

memCached: u64

Memory cached in slabs.

memUsed: u64

Memory used in slabs.

memTotal: u64

Total memory: used or cached.

num: Num

Counters.

slots: Slot

Slots stats.

fn vrt_gc_init()

Initialise the GC.

fn vrt_gc_get_alloc_dg() AllocDg

Get an instance of the AllocDg delegate.

fn vrt_gc_collect()

Perform a collection.

fn vrt_gc_shutdown()

Shutdown the GC, call all destructors, free all memory.

fn vrt_gc_get_stats(stats: Stats) Stats*

Fill out a given Stats struct.