Allocation related methods and classes.
More...
Allocation related methods and classes.
◆ debug_alloc()
Creates a memory allocator using the standard's malloc under the hood This allocator will do basic tracking of memory allocations Once all instances of std_alloc are de-initialized, it will then check to see if any memory is being leakd.
If memory would be leaked, it will return an error in the deinit method.
This allocator assumes that memory maybe passed between instances of std_alloc_global so it will only do a memory check once ALL std_alloc_global allocators are deinitialized, not just when one is.
RECOMMENDED USAGE: It is recommended to only have one instance of this allocator globally, and then to pass that allocator everywhere
- Returns
- Allocator that uses malloc under the hood
◆ debug_alloc_thread_local()
NOT THREAD SAFE!
Creates a debug memory allocator that does memory leak detection. This allocator will do basic tracking of memory allocations When deinitialized, it will then check it's state to see if any memory is leaked. If memory is leaked, it will return an error in the deinit method.
RECOMMENDED USAGE: It is recommended to only have one instance of this allocator per thread, and then to pass that allocator everywhere
- Returns
- Allocator that uses malloc under the hood and does memory tracking
◆ dynamic_arena()
Creates a dynamically growing arena allocator This arena allocator will grow if it runs out of space The allocator will clean all pages on deinit, and reallocate them again when the next allocation happens It does iterate through all pages, so it's \(O(p)\) to allocate Use maxElementHint (max element size) and maxCountHint (max number of elements per page) to hint at page size.
- Parameters
-
root | Pointer to base allocator to use (must be in memory address stable) |
elementSizeHint | Hint for most likely size of elements. Used for initial allocation |
elementCountHint | hint for most likely count of elements. Used for initial allocation |
◆ dynamic_arena_thread_local()
NOT THREAD SAFE!
Creates a dynamically growing arena allocator This arena allocator will grow if it runs out of space The allocator will clean all pages on deinit, and reallocate them again when the next allocation happens It does iterate through all pages, so it's \(O(p)\) to allocate Use maxElementHint (max element size) and maxCountHint (max number of elements per page) to hint at page size
- Parameters
-
root | Pointer to base allocator to use (must be in memory address stable) |
elementSizeHint | Hint for most likely size of elements. Used for initial allocation |
elementCountHint | hint for most likely count of elements. Used for initial allocation |
◆ fixed_arena()
Creates basic arena allocator which just pushes more state onto the end Calling deinit will simply reset the stack pointer.
Safe to reuse after deinit No reallocation supported, free is a noop, no compaction
Uses a fixed size buffer for allocations. Will fail to allocate once buffer is exhausted
- Parameters
-
bytes | Slice to section of memory that will be used by the allocator. Must be valid for allocator lifetime |
- Returns
- Arena allocator that is limited to a fixed buffer
◆ fixed_arena_thread_local()
NOT THREAD SAFE!
Creates basic arena allocator which just pushes more state onto the end Calling deinit will simply reset the stack pointer. Safe to reuse after deinit No reallocation supported, free is a noop, no compaction
Uses a fixed size buffer for allocations. Will fail to allocate once buffer is exhausted
- Parameters
-
bytes | Slice to section of memory that will be used by the allocator. Must be valid for allocator lifetime |
- Returns
- Arena allocator that is limited to a fixed buffer
◆ fixed_buff()
Creates an allocator that works on a fixed buffer of bytes.
Uses same implementation as
- See also
- fixed_buff_thread_local
- Parameters
-
bytes | Slice to section of memory that will be used by the allocator. Must be valid for allocator lifetime |
- Returns
- Allocator that is limited to a fixed buffer
◆ fixed_buff_thread_local()
NOT THREAD SAFE!
Creates an allocator that works on a fixed buffer of bytes. Currently, this uses a simple free list with very basic compaction. May revisit implementation in the future
- Parameters
-
bytes | Slice to section of memory that will be used by the allocator. Must be valid for allocator lifetime |
- Returns
- Allocator that is limited to a fixed buffer. Not thread safe
◆ malloc_alloc()
Creates a memory allocator using the standard's malloc under the hood Does no memory tracking Ideal for production/release/high performance.
- Returns
- Allocator that uses malloc under the hood