Allocator for temporary used memory. More...
#include <temporaryMemory.hpp>
Public Member Functions | |
template<typename T > | |
T * | alloc (size_t size) |
Allocate an array of type T with length size . Data is zero initialized. No constructors of T are called. | |
template<typename T , typename... Args> | |
T * | allocAndInit (Args &&... args) |
Allocate a single entity of T and call the constructor with args . | |
void | ensureSize (size_t newSize) |
void | free () |
Free all allocated memory. No destructors are called. Stored pointers and resources need to be deallocated manually beforehand. | |
bool | isEmpty () |
Returns true if no data is currently allocated. | |
TemporaryMemory () | |
Constructor. | |
TemporaryMemory (size_t initialSize) | |
Constructor. | |
Static Public Attributes | |
static size_t constexpr | InitialDataSize = 4 * 1024 * 1024 |
4 MiB of memory. | |
Allocator for temporary used memory.
Can be used in places where memory is often allocated and deallocated. This reduces reduce the overhead of the system calls.
The initial memory is 4 MiB and can be extended with a call to ensureSize. All memory is initialized with zeros.
|
inline |
Ensures that enough space is available. Can only be called when no data has been allocated because reallocations invalidate pointers.