CppCommon
1.0.4.1
C++ Common Library
|
Arena memory manager class. More...
#include <allocator_arena.h>
Public Member Functions | |
ArenaMemoryManager (TAuxMemoryManager &auxiliary) | |
Initialize arena memory manager with an auxiliary memory manager. More... | |
ArenaMemoryManager (TAuxMemoryManager &auxiliary, size_t capacity) | |
Initialize arena memory manager with an auxiliary memory manager and a given page capacity. More... | |
ArenaMemoryManager (TAuxMemoryManager &auxiliary, void *buffer, size_t capacity) | |
Initialize arena memory manager with an auxiliary memory manager and a given buffer. More... | |
ArenaMemoryManager (const ArenaMemoryManager &)=delete | |
ArenaMemoryManager (ArenaMemoryManager &&)=delete | |
~ArenaMemoryManager () | |
ArenaMemoryManager & | operator= (const ArenaMemoryManager &)=delete |
ArenaMemoryManager & | operator= (ArenaMemoryManager &&)=delete |
size_t | allocated () const noexcept |
Allocated memory in bytes. More... | |
size_t | allocations () const noexcept |
Count of active memory allocations. More... | |
const uint8_t * | buffer () const noexcept |
Arena buffer. More... | |
size_t | capacity () const noexcept |
Arena capacity. More... | |
size_t | size () const noexcept |
Arena allocated size. More... | |
size_t | max_size () const noexcept |
Maximum memory block size, that could be allocated by the memory manager. More... | |
TAuxMemoryManager & | auxiliary () noexcept |
Auxiliary memory manager. More... | |
void * | malloc (size_t size, size_t alignment=alignof(std::max_align_t)) |
Allocate a new memory block of the given size. More... | |
void | free (void *ptr, size_t size) |
Free the previously allocated memory block. More... | |
void | reset () |
Reset the memory manager. More... | |
void | reset (size_t capacity) |
Reset the memory manager with a given page capacity. More... | |
void | reset (void *buffer, size_t capacity) |
Reset the memory manager with a given buffer. More... | |
void | clear () |
Clear arena memory allocator. More... | |
Arena memory manager class.
Arena memory manager uses pre-allocated memory buffer (arena) as a first source of memory during the allocation. If arena buffer has insufficient space to allocate the required block then an auxiliary memory manager will be used.
Arena memory manager is suitable for multiple allocations during long operations with a single reset at the end (e.g. HTTP request processing).
Not thread-safe.
Definition at line 29 of file allocator_arena.h.
|
inlineexplicit |
Initialize arena memory manager with an auxiliary memory manager.
Arena page capacity will be 65536.
auxiliary | - Auxiliary memory manager |
Definition at line 38 of file allocator_arena.h.
|
inlineexplicit |
Initialize arena memory manager with an auxiliary memory manager and a given page capacity.
auxiliary | - Auxiliary memory manager |
capacity | - Arena page capacity in bytes |
Definition at line 12 of file allocator_arena.inl.
|
inlineexplicit |
Initialize arena memory manager with an auxiliary memory manager and a given buffer.
auxiliary | - Auxiliary memory manager |
buffer | - Arena buffer |
capacity | - Arena buffer capacity |
Definition at line 27 of file allocator_arena.inl.
|
delete |
|
delete |
|
inline |
Definition at line 54 of file allocator_arena.h.
|
inlinenoexcept |
Allocated memory in bytes.
Definition at line 60 of file allocator_arena.h.
|
inlinenoexcept |
Count of active memory allocations.
Definition at line 62 of file allocator_arena.h.
|
inlinenoexcept |
Auxiliary memory manager.
Definition at line 75 of file allocator_arena.h.
|
inlinenoexcept |
Arena buffer.
Definition at line 65 of file allocator_arena.h.
|
inlinenoexcept |
Arena capacity.
Definition at line 67 of file allocator_arena.h.
|
inline |
Clear arena memory allocator.
Definition at line 217 of file allocator_arena.inl.
|
inline |
Free the previously allocated memory block.
ptr | - Pointer to the memory block |
size | - Block size |
Definition at line 139 of file allocator_arena.inl.
|
inline |
Allocate a new memory block of the given size.
size | - Block size |
alignment | - Block alignment (default is alignof(std::max_align_t)) |
Definition at line 42 of file allocator_arena.inl.
|
inlinenoexcept |
Maximum memory block size, that could be allocated by the memory manager.
Definition at line 72 of file allocator_arena.h.
|
delete |
|
delete |
|
inline |
Reset the memory manager.
Definition at line 162 of file allocator_arena.inl.
|
inline |
Reset the memory manager with a given page capacity.
capacity | - Arena page capacity in bytes |
Definition at line 175 of file allocator_arena.inl.
|
inline |
Reset the memory manager with a given buffer.
buffer | - Arena buffer |
capacity | - Arena buffer capacity |
Definition at line 195 of file allocator_arena.inl.
|
inlinenoexcept |
Arena allocated size.
Definition at line 69 of file allocator_arena.h.