![]() |
Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
Linear allocator (also known as an arena allocator or bump allocator) is a simple and fast system that allocates memory sequentially from a single growing memory buffer. More...
#include <LinearAllocator.h>

Public Member Functions | |
| LinearAllocator (const std::size_t initialSize, const std::size_t maxCapacity) | |
| ~LinearAllocator () | |
| void * | allocate (std::size_t n, std::size_t alignment) |
| void | deallocate (void *ptr, std::size_t n) |
| std::size_t | GetSize () const |
| std::size_t | GetCapacity () const |
| void | Release () |
Private Attributes | |
| std::size_t | m_Size {0u} |
| std::size_t | m_Capacity |
| std::size_t | m_MaxCapacity |
| std::unique_ptr< std::byte[]> | m_Buffer |
| std::uint32_t | m_AllocationCount {0u} |
| PS::StaticVector< std::unique_ptr< std::byte[]>, 16 > | m_BuffersToFree |
Linear allocator (also known as an arena allocator or bump allocator) is a simple and fast system that allocates memory sequentially from a single growing memory buffer.
Each allocation only moves a free pointer forward. Releasing all allocations happens at the Release call. The allocated memory is not initialized.
It's not thread-safe.
It's intendent to use for allocations with a short lifespan (f.e. function scoped).
There is std::pmr::monotonic_buffer_resource but it doesn't provide information about the current capacity and doesn't allow to limit the capacity. Also avoiding virtual calls for frequent allocations.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |