iz.memory

Memory managment utilities.

Members

Enums

NoGc
enum NoGc

This enum must be used as an UDA to mark a variable of a type that looks like GC-managed but that is actually not GC-managed.

NoInit
enum NoInit

When this enum is used as UDA on aggregate types whose instances are created with construct() they won't be initialized, i.e the static layout representing the initial value of the members is not copied.

TellRangeAdded
enum TellRangeAdded

When this enum is used as UDA on aggregate types whose instances are created with construct() a compile time message indicates if a GC range will be added for the members.

Functions

construct
CT construct(A a)

Returns a new, GC-free, class instance.

construct
Object construct(TypeInfo_Class tic)

Returns a new, GC-free, class instance.

construct
ST* construct(A a)

Returns a new, GC-free, pointer to a struct or to an union.

copyMem
Ptr copyMem(Ptr dst, Ptr src, size_t count)

Like memmove() but for @safe context. dst and src can't overlap.

destruct
void destruct(auto ref T* instance)

Destructs a struct or a union that's been previously constructed with construct().

destruct
void destruct(ref T instance)

Destructs a struct or a union that's allocated within another aggregate that's not GC-managed.

destruct
void destruct(auto ref T instance)

Destructs a class that's been previously constructed with construct() and when the static type is known.

destruct
void destruct(auto ref T instance)

Destructs a class that's been previously constructed with construct() and when the static type is not known.

destruct
void destruct(auto ref T instance)

Destructs an interface implemented in an Object that's been previously constructed with construct().

destruct
void destruct(auto ref T* instance)

Destructs on pointers simply forwards freeMem.

destructEach
void destructEach(auto ref Objs objs)

Frees and invalidates a list of classes instances or struct pointers. destruct() is called for each item.

factory
Object factory(ref F f, string className)

Constructs a class instance using a gc-free factory. The usage is similar to Object.factory() except that by default registered classes don't take the module in account.

freeMem
void freeMem(auto ref T src)

Frees a manually allocated pointer to a basic type. Like free() but for @safe context.

getMem
Ptr getMem(size_t size)

Like malloc() but for @safe context.

moveMem
Ptr moveMem(Ptr dst, const Ptr src, size_t count)

Like memmove() but for @safe context. dst and src can overlap.

newPtr
T* newPtr(A a)

Returns a pointer to a new, GC-free, basic variable. Any variable allocated using this function must be manually freed with freeMem.

reallocMem
Ptr reallocMem(ref Ptr src, size_t newSize)

Like realloc() but for @safe context.

registerFactoryClass
void registerFactoryClass(ref F f, string name = "")

Register a class type that can be created dynamically, using its name.

registerFactoryClasses
void registerFactoryClasses(ref F f)

Calls registerClass() for each template argument.

Mixin templates

disableNew
mixin template disableNew()

When mixed in a aggregate this template has for effect to disable the usage the new operator.

inheritedDtor
mixin template inheritedDtor()

When mixed in class this template has for effect to automatically call the nearest inherited destructor if no destructor is present, otherwise a call to callInheritedDtor() should be made in the last LOC of the destructor.

Templates

MustAddGcRange
template MustAddGcRange(T)

Indicates if an aggregate contains members that might be collected by the garbage collector. This is used in construct to determine if the content of a manually allocated aggregate must be declared to the GC.

Meta