Open 3D Engine AzCore API Reference  22.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
AZ::SystemAllocator Class Reference

#include <SystemAllocator.h>

Inherits AZ::AllocatorBase.


struct  Descriptor

Public Member Functions

bool Create (const Descriptor &desc)
void Destroy () override
 All allocators must provide their deinitialization routine here.
AllocatorDebugConfig GetDebugConfig () override
 Returns the debug configuration for this allocator.
pointer_type Allocate (size_type byteSize, size_type alignment, int flags=0, const char *name=0, const char *fileName=0, int lineNum=0, unsigned int suppressStackRecord=0) override
void DeAllocate (pointer_type ptr, size_type byteSize=0, size_type alignment=0) override
pointer_type ReAllocate (pointer_type ptr, size_type newSize, size_type newAlignment) override
 Realloc an allocate memory memory block. Similar to Resize except it will move the memory block if needed. Return NULL if realloc is not supported or run out of memory.
size_type Resize (pointer_type ptr, size_type newSize) override
 Resize an allocated memory block. Returns the new adjusted size (as close as possible or equal to the requested one) or 0 (if you don't support resize at all).
size_type AllocationSize (pointer_type ptr) override
 Returns allocation size for given address. 0 if the address doesn't belong to the allocator.
void GarbageCollect () override
size_type NumAllocatedBytes () const override
size_type Capacity () const override
 Returns the capacity of the Allocator in bytes. If the return value is 0 the Capacity is undefined (usually depends on another allocator)
size_type GetMaxAllocationSize () const override
 Keep in mind this operation will execute GarbageCollect to make sure it returns, max allocation. This function WILL be slow.
size_type GetMaxContiguousAllocationSize () const override
 Returns the maximum contiguous allocation size of a single allocation.
size_type GetUnAllocatedMemory (bool isPrint=false) const override
- Public Member Functions inherited from AZ::AllocatorBase
const char * GetName () const override
const char * GetDescription () const override
Debug::AllocationRecordsGetRecords () final
 Returns a pointer to the allocation records. They might be available or not depending on the build type. Debug::AllocationRecords.
void SetRecords (Debug::AllocationRecords *records) final
 Sets the allocation records.
bool IsReady () const final
 Returns true if this allocator is ready to use.
void PostCreate () override
 All conforming allocators must call PostCreate() after their custom Create() method in order to be properly registered.
void PreDestroy () final
 All conforming allocators must call PreDestroy() before their custom Destroy() method in order to be properly deregistered.
void SetLazilyCreated (bool lazy) final
bool IsLazilyCreated () const final
 Returns true if the allocator was lazily created. Exposed primarily for testing systems that need to verify the state of allocators.
void SetProfilingActive (bool active) final
bool IsProfilingActive () const final
 Returns true if profiling calls will be made.
- Public Member Functions inherited from AZ::IAllocator
 IAllocator (IAllocatorSchema *schema=nullptr)
AZ_FORCE_INLINE IAllocatorSchemaGetSchema () const
 Returns the schema.

Protected Member Functions

 SystemAllocator (const SystemAllocator &)
SystemAllocatoroperator= (const SystemAllocator &)
- Protected Member Functions inherited from AZ::AllocatorBase
 AllocatorBase (IAllocatorSchema *allocationSchema, const char *name, const char *desc)
AZ_FORCE_INLINE size_t MemorySizeAdjustedUp (size_t byteSize) const
 Returns the size of a memory allocation after adjusting for tracking.
AZ_FORCE_INLINE size_t MemorySizeAdjustedDown (size_t byteSize) const
 Returns the size of a memory allocation, removing any tracking overhead.
void DisableRegistration ()
void ProfileAllocation (void *ptr, size_t byteSize, size_t alignment, const char *name, const char *fileName, int lineNum, int suppressStackRecord)
 Records an allocation for profiling.
void ProfileDeallocation (void *ptr, size_t byteSize, size_t alignment, Debug::AllocationInfo *info)
 Records a deallocation for profiling.
void ProfileReallocationBegin (void *ptr, size_t newSize)
 Records a reallocation for profiling.
void ProfileReallocationEnd (void *ptr, void *newPtr, size_t newSize, size_t newAlignment)
 Records the beginning of a reallocation for profiling.
void ProfileReallocation (void *ptr, void *newPtr, size_t newSize, size_t newAlignment)
void ProfileResize (void *ptr, size_t newSize)
 Records a resize for profiling.
bool OnOutOfMemory (size_t byteSize, size_t alignment, int flags, const char *name, const char *fileName, int lineNum)
 User allocator should call this function when they run out of memory!

Protected Attributes

Descriptor m_desc
bool m_isCustom
bool m_ownsOSAllocator
- Protected Attributes inherited from AZ::IAllocator

Additional Inherited Members

- Public Types inherited from AZ::IAllocatorSchema
typedef void * pointer_type
typedef size_t size_type
typedef ptrdiff_t difference_type

Detailed Description

System allocator The system allocator is the base allocator for AZ memory lib. It is a singleton (like all other allocators), but must be initialized first and destroyed last. All other allocators will use them for internal allocations. This doesn't mean all other allocators will be sub allocators, because we might have different memory system on consoles. But the allocator utility system will use the system allocator.

Member Function Documentation

◆ GarbageCollect()

void AZ::SystemAllocator::GarbageCollect ( )

Call from the system when we want allocators to free unused memory. IMPORTANT: This function is/should be thread safe. We can call it from any context to free memory. Freeing the actual memory is optional (if you can), thread safety is a must.

Reimplemented from AZ::IAllocatorSchema.

◆ GetUnAllocatedMemory()

size_type AZ::SystemAllocator::GetUnAllocatedMemory ( bool  isPrint = false) const

Returns memory allocated by the allocator and available to the user for allocations. IMPORTANT: this is not the overhead memory this is just the memory that is allocated, but not used. Example: the pool allocators allocate in chunks. So we might be using one elements in that chunk and the rest is free/unallocated. This is the memory that will be reported.

Reimplemented from AZ::IAllocatorSchema.

The documentation for this class was generated from the following file: