![]() |
ezEngine Release 26.3
|
Base class for all memory allocators. More...
#include <Allocator.h>

Classes | |
| struct | Stats |
Public Member Functions | |
| virtual void * | Allocate (size_t uiSize, size_t uiAlign, ezMemoryUtils::DestructorFunction destructorFunc=nullptr)=0 |
| Interface, do not use this directly, always use the new/delete macros below. | |
| virtual void | Deallocate (void *pPtr)=0 |
| Deallocates memory previously allocated by this allocator. | |
| virtual void * | Reallocate (void *pPtr, size_t uiCurrentSize, size_t uiNewSize, size_t uiAlign) |
| Reallocates memory, potentially moving the data to a new location. | |
| virtual size_t | AllocatedSize (const void *pPtr)=0 |
| Returns the number of bytes allocated at this address. | |
| virtual ezAllocatorId | GetId () const =0 |
| virtual Stats | GetStats () const =0 |
Base class for all memory allocators.
This abstract base class defines the interface for all allocators in ezEngine. Allocators are responsible for memory management and can implement different allocation strategies (heap, linear, frame, etc.).
Key concepts:
Usage:
|
pure virtual |
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).
Implemented in ezLinearAllocator< TrackingMode, OverwriteMemoryOnReset >, ezLinearAllocator< ezAllocatorTrackingMode::Basics >, ezLinearAllocator< ezAllocatorTrackingMode::Nothing >, ezInternal::ezAllocatorImpl< AllocationPolicy, TrackingMode >, ezInternal::ezAllocatorImpl< ezAllocPolicyHeap, TrackingMode >, ezInternal::ezAllocatorImpl< ezAllocPolicyLinear< false >, TrackingMode >, and ezInternal::ezAllocatorImpl< ezAllocPolicyProxy, TrackingMode >.
|
pure virtual |
Returns the number of bytes allocated at this address.
This information is only available if allocation tracking is enabled (see ezAllocatorTrackingMode and EZ_ALLOC_TRACKING_DEFAULT). Returns 0 when tracking is disabled or for invalid pointers. Primarily used for debugging and memory analysis.
Implemented in ezInternal::ezAllocatorImpl< AllocationPolicy, TrackingMode >, ezInternal::ezAllocatorImpl< ezAllocPolicyHeap, TrackingMode >, ezInternal::ezAllocatorImpl< ezAllocPolicyLinear< false >, TrackingMode >, and ezInternal::ezAllocatorImpl< ezAllocPolicyProxy, TrackingMode >.
|
pure virtual |
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.
Implemented in ezInternal::ezAllocatorImpl< AllocationPolicy, TrackingMode >, ezInternal::ezAllocatorImpl< ezAllocPolicyHeap, TrackingMode >, ezInternal::ezAllocatorImpl< ezAllocPolicyLinear< false >, TrackingMode >, ezInternal::ezAllocatorImpl< ezAllocPolicyProxy, TrackingMode >, ezLinearAllocator< TrackingMode, OverwriteMemoryOnReset >, ezLinearAllocator< ezAllocatorTrackingMode::Basics >, and ezLinearAllocator< ezAllocatorTrackingMode::Nothing >.
|
virtual |
Reallocates memory, potentially moving the data to a new location.
Default implementation allocates new memory, copies old data, and deallocates the old memory. Some allocators may provide more efficient implementations.
Reimplemented in ezInternal::ezAllocatorMixinReallocate< AllocationPolicy, TrackingMode, true >.