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]
  2. void theAllocator [@property getter]
    nothrow @safe @nogc @property


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