class
FrameAllocator
Frame allocator.
Performs very fast allocations using a bump allocator pattern but can only free all of its memory at once. Perfect for allocations that last just a single frame.
Frames can be nested within each other using MarkFrame() and Clear(). Each MarkFrame() increases the frame depth, and Clear() decreases it. Memory allocated at a specific depth must be freed at the same depth. In debug builds, attempting to free memory at a different depth than it was allocated will trigger an assertion.
Public
Constructors
FrameAllocator
Methods
~FrameAllocator
Allocate
Allocates a new block of memory of the specified size.
- allocationSize
- Amount of memory to allocate, in bytes.
AllocateAligned
Allocates a new block of memory of the specified size aligned to the specified boundary.
If the aligment is less or equal to 16 it is more efficient to use the AllocAligned16() alternative of this method.
- allocationSize
- Amount of memory to allocate, in bytes.
- alignment
- Alignment of the allocated memory. Must be power of two.
Free
Deallocates a previously allocated block of memory.
MarkFrame
Marks the beginning of a new frame scope.
Increments the frame depth counter. The next call to Clear() will only clear memory allocated past this point.
Private
Methods
AllocateBlock
Allocates a dynamic block of memory of the wanted size.
The exact allocation size might be slightly higher in order to store block meta data.