std.allocators.gc
This module contains a struct that wraps D's builtin garbage collected allocator in an allocator interface as described in std.allocators.allocator. Author:David Simcha License:
Boost License 1.0.
- This struct provides an interface to D's garbage collector using the standard
allocator interface.
- This variable controls whether memory allocated via allocate may contain pointers and should be scanned by the garbage collector. This does not affect memory allocated by create, newArray, array or uninitializedArray since these functions have type information available. The default is true.
- Forwards to core.memory.GC.malloc and sets the GC.BlkAttr.NO_SCAN bit if scanForPointers is false.
- Forwards to core.memory.GC.free.
- Forwards to core.memory.GC.extend.
- False because the GC doesn't do any checking to ensure that free'd pointers are valid.
- The GC aligns allocations of <16 bytes to 16 bytes, allocations between 16 bytes and the page size to the next larger power of two, and allocations greater than a page size to page boundaries.
- The GC rounds allocations of less than 16 bytes to 16 bytes, allocations of between 16 bytes and a page to the next power of two, and allocations greater than a page to the nearest page.
- True because this is just a wrapper around the GC and gets automatically reclaimed.
- False because GC allocated memory is not freed deterministically when this allocator goes out of scope.
- Forwards to the new operator for classes.
- Forwards to the new operator for non-class objects.
- Forwards to the new operator for arrays.
auto alloc = GCAllocator.init; // The following are equivalent: auto arr = new int[][](42, 86); auto arr = alloc.newArray!(int[][])(42, 86);
- Same as newArray except skips initialization of elements.
- Forwards to std.array.array.
- Returns a std.allocators.allocator.DynamicAllocator using this as the underlying allocator. The DynamicAllocator is allocated on the GC heap.