7#include <Common/primitive_type.h>
8#include <Common/memory.h>
33 MemoryArena(std::size_t blockSizeHintInBytes, std::size_t numDefaultBlocks);
57 std::byte*
allocRaw(std::size_t numBytes, std::size_t alignmentInBytes =
alignof(std::max_align_t));
100 template<
typename T,
typename... Args>
101 T*
make(Args&&... args);
104 std::vector<TAlignedMemoryUniquePtr<std::byte>> m_blocks;
106 std::size_t m_blockSizeInBytes;
107 std::size_t m_currentBlockIdx;
108 std::byte* m_blockPtr;
109 std::size_t m_remainingBytesInBlock;
110 std::size_t m_numUsedBytes;
115 std::vector<
TFunction<void(
void), 0>> m_dtorCallers;
Marks the derived class as move only.
Definition IMoveOnly.h:23
A general purpose bump allocator.
Definition MemoryArena.h:21
~MemoryArena()
Definition MemoryArena.cpp:71
std::size_t numAllocatedBytes() const
Definition MemoryArena.ipp:15
TSpan< T > allocArray(const std::size_t arraySize)
Allocate raw memory for array of type T. Convenient method for allocating raw memory for array of typ...
Definition MemoryArena.ipp:42
T * alloc()
Allocate raw memory for type T. Convenient method for allocating raw memory for object of type T....
Definition MemoryArena.ipp:31
std::size_t numUsedBytes() const
Definition MemoryArena.ipp:10
std::size_t getBlockSizeInBytes() const
Definition MemoryArena.ipp:20
MemoryArena(MemoryArena &&other)=default
Move another arena into this one. The moved-from arena cannot be used unless:
std::size_t numAllocatedBlocks() const
Definition MemoryArena.ipp:25
std::byte * allocRaw(std::size_t numBytes, std::size_t alignmentInBytes=alignof(std::max_align_t))
Allocate raw memory. Generally speaking, the memory returned contains no object–placement new is requ...
Definition MemoryArena.cpp:78
MemoryArena & operator=(MemoryArena &&rhs)=default
T * make(Args &&... args)
Make an object of type T. Convenient method for creating an object without needing a placement new la...
Definition MemoryArena.ipp:55
MemoryArena()
Empty arena without any allocation performed yet.
Definition MemoryArena.cpp:44
void clear()
Reset the usage of the arena. All memory handed out are effectively deallocated/deleted after this ca...
Definition MemoryArena.cpp:141
Definition TFunction.h:23
The root for all renderer implementations.
Definition EEngineProject.h:6
std::span< T, EXTENT > TSpan
A contiguous sequence of objects of type T. Effectively the same as std::span.
Definition TSpan.h:12