132 Heap(const
unsigned long long AInitialCommitSize);
158 bool Locked(
void) const noexcept;
187 void Walk(
void) const;
190 void*
Alloc(const
int ASize) final override;
192 void*
Realloc(
void* const APreviousAllocation, const
int ANewSize) final override;
194 void Free(
void* const APreviousAllocation) noexcept final override;
void Unlock(void)
Unlock the Heap, allowing reads and writes to the owned memory.
Block & AllocImpl(unsigned int ANumBytes, API::LockGuard &ALock)
Allocates a Block.
Platform::System::Mutex FMutex
The lock for the Heap.
void Lock(void)
Lock the Heap, preventing reads and writes to the owned memory.
A RAII locking mechanism.
unsigned long long CurrentAmountOfMemoryCommitted(void) const noexcept
Retrieve the amount of memory currently committed by the heap.
A memory pool manager and allocator.
unsigned long long TotalNumberOfAllocations(void) const noexcept
Retrieve the number of allocations over the Heap's lifetime.
unsigned long long CurrentNumberOfAllocations(void) const noexcept
Retrieve the current of allocations in the heap. Implicitly unlocks the Heap for the duration of the ...
bool FLocked
Whether or not the Heap is currently locked.
Used to identify the end of a Heap.
void Walk(void) const
Walks the heap blocks and free list and HCFs if an error is detected.
Block * FFreeList
The first block in the linked free list.
void FreeImpl(Block &ABlock, API::LockGuard &ALock) noexcept(!API::Platform::IsDebug())
Frees a Block.
void * Alloc(const int ASize) finaloverride
Allocate memory from the heap for use.
void WalkImpl(API::LockGuard &ALock) const
Walks the heap blocks and free list and throws if an error is detected.
static void AllocCheck(void)
Used by the testing suite to fail allocations at will.
static unsigned long long CalculateInitialCommitSize(const unsigned long long AInitialCommitSize) noexcept
A small max comparison of AInitialCommitSize and sizeof(Block) + 1.
void MergeBlockIfPossible(Block *&ABlock, Block *const ALastFreeListEntry) noexcept
Coalesces Blocks to the left of ABlock and updates the free list.
Platform::System::VirtualMemory FReservation
The VirtualMemory mapping owned by the heap, also a pointer to the first block.
void Free(void *const APreviousAllocation) noexceptfinaloverride
Return memory to the heap. Data in allocated range will be lost.
void LargeBlockNeedsAtLeast(unsigned int ARequiredNumBytes)
Ensures that FLargeBlock has at least ARequiredNumBytes of Size by committing more memory if necessar...
Block & ReallocImpl(Block &ABlock, unsigned int ANumBytes, API::LockGuard &ALock)
Reallocates a Block.
An interface which can allocate memory.
void * Realloc(void *const APreviousAllocation, const int ANewSize) finaloverride
Allocate memory from the heap for use while preserving previous data. Passing a valid APreviousAlloca...
A unit of memory allocation.
LargeBlock * FLargeBlock
The block that extends to the end of the free list.
bool Locked(void) const noexcept
Check and see if the Heap is currently locked.
void RemoveFromFreeList(Block &ABlock, Block *const APreviousEntry) noexcept
Removes a Block from the free list after APreviousEntry while performing all the checks and reassignm...
Block & FirstBlock(void) noexcept
Get a reference to the first block in the reservation.
void AddToFreeList(Block &ABlock, Block *const APreviousEntry) noexcept
Adds a Block to the free list after APreviousEntry while performing all the checks and reassignments...