stdx.allocator.gc_allocator
-
Declaration
struct
GCAllocator
;D's built-in garbage-collected allocator.
Examples
auto buffer = GCAllocator.instance.allocate(1024 * 1024 * 4); // deallocate upon scope's end (alternatively: leave it to collection) scope(exit) GCAllocator.instance.deallocate(buffer); //...
-
Declaration
enum uint
alignment
;The
alignment
is a static constant equal to , which ensures properalignment
for any D data type. -
Declaration
shared pure nothrow @trusted void[]
allocate
(size_tbytes
);
shared @system boolexpand
(ref void[]b
, size_tdelta
);
shared pure nothrow @system boolreallocate
(ref void[]b
, size_tnewSize
);
shared pure nothrow TernaryresolveInternalPointer
(const void*p
, ref void[]result
);
shared pure nothrow @system booldeallocate
(void[]b
);
shared size_tgoodAllocSize
(size_tn
);Standard allocator methods per the semantics defined above. The and methods are because they may move memory around, leaving dangling pointers in user code.
-
Declaration
static shared GCAllocator
instance
;Returns the global
instance
of this allocator type. The garbage collected allocator is thread-safe, therefore all of its methods and
itself are .instance