#include <MixedStackHeapAllocator.h>
Public Member Functions | |
| AZ_TYPE_INFO (mixed_stack_heap_allocator, "{49B6706B-716F-42F2-92CB-7FD1A57BE2F9}") | |
| mixed_stack_heap_allocator (const mixed_stack_heap_allocator &rhs) | |
| mixed_stack_heap_allocator & | operator= (const mixed_stack_heap_allocator &rhs) |
| pointer | allocate (size_type byteSize, size_type alignment, int flags=0) |
| void | deallocate (pointer ptr, size_type byteSize, size_type alignment) |
| pointer | reallocate (pointer ptr, size_type newSize, align_type newAlignment=1) const |
| size_type | max_size () const |
| size_type | NumAllocatedBytes () const |
| constexpr bool | is_lock_free () const |
| constexpr bool | is_stale_read_allowed () const |
| constexpr bool | is_delayed_recycling () const |
Friends | |
| bool | operator== (const mixed_stack_heap_allocator &a, const mixed_stack_heap_allocator &b) |
This allocator is a hybrid between a stack-based allocator and a heap-based allocator. It is intended for use with vector<> as a way to get the performance of fixed_vector<> when few nodes are needed, while still retaining the flexibility of general-purpose resizing when a large number of nodes are needed.
In particular, this is useful for APIs that use a temporary vector<> during processing that is sized based on an input to the API, and the APIs have different use cases that could significantly vary the size requirements.
Usage: vector<T, mixed_stack_heap_allocator<T, N>> tempData;
This will create a vector<T> that pre-allocates space for N nodes on the stack. If the vector attempts to allocate N entries or less, the allocation will come from the stack space. If more than N entries are allocated, or if the vector attempts to grow beyond N entries, the memory will instead come from the heap.
Limitations: