XII Release 0.1.0
Loading...
Searching...
No Matches
xiiAllocator Class Referenceabstract

#include <Allocator.h>

Inheritance diagram for xiiAllocator:
[legend]

Classes

struct  Stats

Public Member Functions

 xiiAllocator ()
 Copyright (c) Theophilus Eriata. All Rights Reserved.
virtual void * Allocate (size_t uiSize, size_t uiAlign, xiiMemoryUtils::DestructorFunction destructorFunc=nullptr)=0
virtual void Deallocate (void *pPtr)=0
virtual void * Reallocate (void *pPtr, size_t uiCurrentSize, size_t uiNewSize, size_t uiAlign)
 Copyright (c) Theophilus Eriata. All Rights Reserved.
virtual size_t AllocatedSize (const void *pPtr)=0
virtual xiiAllocatorId GetId () const =0
virtual Stats GetStats () const =0

Detailed Description

Base class for all memory allocators.

This abstract base class defines the interface for all allocators in xiiEngine. Allocators are responsible for memory management and can implement different allocation strategies (heap, linear, frame, etc.).

Key concepts:

  • All allocators provide aligned memory allocation
  • Optional tracking of allocation statistics and debugging information
  • Virtual interface allows swapping allocator implementations
  • Thread safety depends on specific allocator implementation

Usage:

  • Use XII_NEW/XII_DELETE macros instead of calling Allocate/Deallocate directly
  • Different allocator types optimize for different usage patterns
  • Always pair allocations with deallocations using the same allocator instance

Member Function Documentation

◆ Allocate()

virtual void * xiiAllocator::Allocate ( size_t uiSize,
size_t uiAlign,
xiiMemoryUtils::DestructorFunction destructorFunc = nullptr )
pure virtual

◆ AllocatedSize()

virtual size_t xiiAllocator::AllocatedSize ( const void * pPtr)
pure virtual

Returns the number of bytes allocated at this address.

This information is only available if allocation tracking is enabled (see xiiAllocatorTrackingMode and XII_ALLOC_TRACKING_DEFAULT). Returns 0 when tracking is disabled or for invalid pointers. Primarily used for debugging and memory analysis.

Implemented in xiiInternal::xiiAllocatorImpl< AllocationPolicy, TrackingMode >, xiiInternal::xiiAllocatorImpl< xiiAllocationPolicyHeap, TrackingMode >, xiiInternal::xiiAllocatorImpl< xiiAllocationPolicyLinear< false >, TrackingMode >, and xiiInternal::xiiAllocatorImpl< xiiAllocationPolicyProxy, TrackingMode >.

◆ Deallocate()

◆ Reallocate()

void * xiiAllocator::Reallocate ( void * pPtr,
size_t uiCurrentSize,
size_t uiNewSize,
size_t uiAlign )
virtual

Copyright (c) Theophilus Eriata. All Rights Reserved.

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 xiiInternal::xiiAllocatorMixinReallocate< AllocationPolicy, TrackingMode, true >.


The documentation for this class was generated from the following files:
  • /home/runner/work/XII/XII/Source/Engine/Foundation/Memory/Allocator.h
  • /home/runner/work/XII/XII/Source/Engine/Foundation/Memory/Implementation/Allocator.cpp
  • /home/runner/work/XII/XII/Source/Engine/Foundation/Memory/Implementation/Allocator_inl.h