theAllocator

Gets/sets the allocator for the current thread. This is the default allocator that should be used for allocating thread-local memory. For allocating memory to be shared across threads, use processAllocator (below). By default, theAllocator ultimately fetches memory from processAllocator, which in turn uses the garbage collected heap.

  1. IAllocator theAllocator [@property getter]
    version(HasDRuntime)
    nothrow @safe @nogc @property
    theAllocator
    ()
  2. void theAllocator [@property getter]

Examples

// Install a new allocator that is faster for 128-byte allocations.
import stdx.allocator.building_blocks.free_list : FreeList;
import stdx.allocator.gc_allocator : GCAllocator;
auto oldAllocator = theAllocator;
scope(exit) theAllocator = oldAllocator;
theAllocator = allocatorObject(FreeList!(GCAllocator, 128)());
// Use the now changed allocator to allocate an array
const ubyte[] arr = theAllocator.makeArray!ubyte(128);
assert(arr.ptr);
//...

Meta