core.internal.gc.impl.manual.gc

This module contains a minimal garbage collector implementation according to published requirements. This library is mostly intended to serve as an example, but it is usable in applications which do not rely on a garbage collector to clean up memory (ie. when dynamic array resizing is not used, and all memory allocated with 'new' is freed deterministically with 'delete').

Please note that block attribute data must be tracked, or at a minimum, the FINALIZE bit must be tracked for any allocated memory block because calling rt_finalize on a non-object block can result in an access violation. In the allocator below, this tracking is done via a leading uint bitmask. A real allocator may do better to store this data separately, similar to the basic GC.

Types 1

classManualGC : GC
Fields
Array!Root roots
Array!Range ranges
Methods
void enable()
void disable()
void collect() nothrow
void minimize() nothrow
uint getAttr(void * p) nothrow
uint setAttr(void * p, uint mask) nothrow
uint clrAttr(void * p, uint mask) nothrow
void * malloc(size_t size, uint bits, const TypeInfo ti) nothrow
BlkInfo qalloc(size_t size, uint bits, const scope TypeInfo ti) nothrow
void * calloc(size_t size, uint bits, const TypeInfo ti) nothrow
void * realloc(void * p, size_t size, uint bits, const TypeInfo ti) nothrow
size_t extend(void * p, size_t minsize, size_t maxsize, const TypeInfo ti) nothrow
size_t reserve(size_t size) nothrow
void free(void * p) nothrow @nogc
void * addrOf(void * p) nothrow @nogcDetermine the base address of the block containing p. If p is not a gc allocated pointer, return null.
size_t sizeOf(void * p) nothrow @nogcDetermine the allocated size of pointer p. If p is an interior pointer or not a gc allocated pointer, return 0.
BlkInfo query(void * p) nothrowDetermine the base address of the block containing p. If p is not a gc allocated pointer, return null.
core.memory.GC.Stats stats() nothrow
core.memory.GC.ProfileStats profileStats() nothrow
void addRoot(void * p) nothrow @nogc
void removeRoot(void * p) nothrow @nogc
RootIterator rootIter() @property return @nogc
private int rootsApply(scope int delegate(ref Root) nothrow dg)
void addRange(void * p, size_t sz, const TypeInfo ti = null) nothrow @nogc
void removeRange(void * p) nothrow @nogc
RangeIterator rangeIter() @property return @nogc
private int rangesApply(scope int delegate(ref Range) nothrow dg)
void runFinalizers(const scope void[] segment) nothrow
bool inFinalizer() nothrow
ulong allocatedInCurrentThread() nothrow
void[] getArrayUsed(void * ptr, bool atomic = false) nothrow
bool expandArrayUsed(void[] slice, size_t newUsed, bool atomic = false) nothrow @safe
size_t reserveArrayCapacity(void[] slice, size_t request, bool atomic = false) nothrow @safe
bool shrinkArrayUsed(void[] slice, size_t existingUsed, bool atomic = false) nothrow
void initThread(ThreadBase t) nothrow @nogc
void cleanupThread(ThreadBase t) nothrow @nogc
Constructors
Destructors

Functions 4

fnnoreturn onOutOfMemoryError(void * pretend_sideffect = null, string file = __FILE__, size_t line = __LINE__) @trusted pure nothrow @nogc
private fnvoid gc_manual_ctor()
private fnGC initialize()