![]() |
ezEngine Release 26.3
|
Stack-based linear allocator that allocates memory sequentially. More...
#include <LinearAllocator.h>

Public Member Functions | |
| ezLinearAllocator (ezStringView sName, ezAllocator *pParent) | |
| virtual void * | Allocate (size_t uiSize, size_t uiAlign, ezMemoryUtils::DestructorFunction destructorFunc) override |
| Interface, do not use this directly, always use the new/delete macros below. | |
| virtual void | Deallocate (void *pPtr) override |
| Deallocates memory previously allocated by this allocator. | |
| void | Reset () |
| Resets the allocator, freeing all memory and calling destructors. | |
Public Member Functions inherited from ezAllocatorWithPolicy< AllocationPolicy, TrackingMode > | |
| ezAllocatorWithPolicy (ezStringView sName, ezAllocator *pParent=nullptr) | |
Public Member Functions inherited from ezInternal::ezAllocatorMixinReallocate< AllocationPolicy, TrackingMode, HasReallocate > | |
| ezAllocatorMixinReallocate (ezStringView sName, ezAllocator *pParent) | |
Public Member Functions inherited from ezInternal::ezAllocatorImpl< AllocationPolicy, TrackingMode > | |
| ezAllocatorImpl (ezStringView sName, ezAllocator *pParent) | |
| virtual size_t | AllocatedSize (const void *pPtr) override |
| Returns the number of bytes allocated at this address. | |
| virtual ezAllocatorId | GetId () const override |
| virtual Stats | GetStats () const override |
| ezAllocator * | GetParent () const |
Public Member Functions inherited from ezAllocator | |
| virtual void * | Reallocate (void *pPtr, size_t uiCurrentSize, size_t uiNewSize, size_t uiAlign) |
| Reallocates memory, potentially moving the data to a new location. | |
Additional Inherited Members | |
Protected Attributes inherited from ezInternal::ezAllocatorImpl< AllocationPolicy, TrackingMode > | |
| AllocationPolicy | m_allocator |
| ezAllocatorId | m_Id |
| ezThreadID | m_ThreadID |
Stack-based linear allocator that allocates memory sequentially.
This allocator allocates memory by simply advancing a pointer within a pre-allocated buffer. Individual deallocations are not supported - the entire allocator must be reset at once. Very efficient for temporary allocations that follow a stack-like pattern.
Template parameters:
Performance characteristics:
Use when:
|
overridevirtual |
Interface, do not use this directly, always use the new/delete macros below.
Allocates aligned memory of the specified size. The destructorFunc parameter is used for automatic cleanup when the allocator is reset or destroyed (mainly used by linear allocators).
Reimplemented from ezInternal::ezAllocatorImpl< AllocationPolicy, TrackingMode >.
|
overridevirtual |
Deallocates memory previously allocated by this allocator.
The pointer must have been returned by a previous call to Allocate() on this allocator instance. Passing nullptr is safe and will be ignored.
Reimplemented from ezInternal::ezAllocatorImpl< AllocationPolicy, TrackingMode >.
| EZ_MSVC_ANALYSIS_WARNING_PUSH void ezLinearAllocator< TrackingMode, OverwriteMemoryOnReset >::Reset | ( | ) |
Resets the allocator, freeing all memory and calling destructors.
This resets the allocation pointer to the beginning and calls destructors for all objects that were allocated with destructor functions. After reset, all previously allocated pointers become invalid and must not be used.