Module dstats.alloc

Stuff having to do with memory management. Mostly a copy of RegionAllocator for now until it gets into Phobos, as well as some RegionAllocator-specific data structures.


David Simcha


appendDelOld(to, from)Appends to an array, deleting the old array if it has to be realloced.
newRegionAllocator()Returns a new RegionAllocator that uses the default thread-local RegionAllocatorStack instance.
scanThreadLocalStack()These properties determine whether the default thread-local RegionAllocatorStack instance is scanned by the garbage collector. The default is no. In most cases, scanning a stack this long-lived is not recommended, as it will cause too many false pointers. (See regionallocator, GCScan for details.)
threadLocalSegmentSize()These properties get and set the segment size of the default thread-local RegionAllocatorStack instance. The default size is 4 megabytes. The setter is only effective before the global function newRegionAllocator has been called for the first time in the current thread. Attempts to set this property after the first call to this function from the current thread throw a RegionAllocatorException.


RegionAllocatorExceptionThe exception that is thrown on invalid use of and RegionAllocatorStack. This exception is not thrown on out of memory. An OutOfMemoryError is thrown instead.


HashRangeForward range struct for iterating over the keys or values of a StackHash or StackSet. The lifetime of this object must not exceed that of the underlying StackHash or StackSet.
RegionAllocatorThis struct provides an interface to the RegionAllocator functionality and enforces scoped deletion. A new instance using the thread-local RegionAllocatorStack instance is created using the global newRegionAllocator function. A new instance using an explicitly created RegionAllocatorStack is created using RegionAllocatorStack.newRegionAllocator.
RegionAllocatorStackThis object represents a segmented stack. Memory can be allocated from this stack using a regionallocator RegionAllocator object. Multiple RegionAllocator objects may be created per RegionAllocatorStack but each RegionAllocator uses a single RegionAllocatorStack.
StackHashA hash table that allocates its memory on RegionAllocator. Good for building a temporary hash tables that will not escape the current scope.
StackSetA hash set that allocates its memory on RegionAllocator. Good for building a temporary set that will not escape the current scope.
StackTreeAn AVL tree implementation on top of RegionAllocator. If elements are removed, they are stored on an internal free list and recycled when new elements are added to the tree.
StackTreeAAAn associative array implementation based on StackTree. Lookups and insertions are O(log N). This is significantly slower in both theory and practice than StackHash, but you may want to use it if:
TreeAaIterStruct that iterates over keys or values of a StackTreeAA.


GCScanThis flag determines whether a given RegionAllocatorStack is scanned for pointers by the garbage collector (GC). If yes, the entire stack is scanned, not just the part currently in use, since there is currently no efficient way to modify the bounds of a GC region. The stack is scanned conservatively, meaning that any bit pattern that would point to GC-allocated memory if interpreted as a pointer is considered to be a pointer. This can result in GC-allocated memory being retained when it should be freed. Due to these caveats, it is recommended that any stack scanned by the GC be small and/or short-lived.

Manifest constants