Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::Debug::AllocationRecords Class Reference

#include <AllocationRecords.h>

Public Types

enum  Mode : int {
  RECORD_NO_RECORDS , RECORD_STACK_NEVER , RECORD_STACK_IF_NO_FILE_LINE , RECORD_FULL ,
  RECORD_MAX
}
 

Public Member Functions

 AllocationRecords (unsigned char stackRecordLevels, bool isMemoryGuard, bool isMarkUnallocatedMemory, const char *allocatorName)
 
unsigned int MemoryGuardSize () const
 
void lock ()
 
bool try_lock ()
 
void unlock ()
 
void SetMode (Mode mode)
 Enabling too much stack recording may cause performance issues. Use wisely.
 
Mode GetMode () const
 
void SetSaveNames (bool saveNames)
 
void SetDecodeImmediately (bool decodeImmediately)
 
unsigned char GetNumStackLevels () const
 Returns number of stack levels that will captured for each allocation when requested (depending on the Mode)
 
AZ_FORCE_INLINE Debug::AllocationRecordsTypeGetMap ()
 Not thread safe!!! Make sure you lock/unlock while you work with the records.
 
void EnumerateAllocations (AllocationInfoCBType cb) const
 Enumerates all allocations in a thread safe manner.
 
void MarkUallocatedMemory (bool isMark)
 If marking is enabled it will set all memory we deallocate with 0xcd.
 
bool IsMarkUnallocatedMemory () const
 
int GetUnallocatedMarkValue () const
 
void IntegrityCheck () const
 Checks the integrity of the allocator. Enabled if isMemoryGuard is set to true. This can be a slow operation.
 
void AutoIntegrityCheck (bool enable)
 Enables IntergrityCheck on allocation and deallocation. Enabled only if isMemoryGuard is set to true. This will cause allocation/deallocation to be VERY SLOW!
 
size_t RequestedBytesPeak () const
 Returns peak of requested memory. IMPORTANT: This is user requested memory! Any allocator overhead is NOT included.
 
void ResetPeakBytes ()
 Reset the peak allocation to the current requested memory.
 
size_t RequestedBytes () const
 Return requested user bytes. IMPORTANT: This is user requested memory! Any allocator overhead is NOT included.
 
size_t RequestedAllocs () const
 Returns total number of requested allocations.
 
const char * GetAllocatorName () const
 
const AllocationInfoRegisterAllocation (void *address, size_t byteSize, size_t alignment, unsigned int stackSuppressCount)
 
void UnregisterAllocation (void *address, size_t byteSize, size_t alignment, AllocationInfo *info)
 
void ResizeAllocation (void *address, size_t newSize)
 
void RegisterReallocation (void *address, void *newAddress, size_t byteSize, size_t alignment, unsigned int stackSuppressCount)
 

Protected Attributes

Debug::AllocationRecordsType m_records
 
AZStd::spin_mutex m_recordsMutex
 
Mode m_mode
 
bool m_isAutoIntegrityCheck
 
bool m_isMarkUnallocatedMemory
 True if we want to set value 0xcd in unallocated memory.
 
bool m_saveNames
 
bool m_decodeImmediately
 
unsigned char m_numStackLevels
 
unsigned int m_memoryGuardSize
 
AZStd::atomic< size_t > m_requestedAllocs
 
AZStd::atomic< size_t > m_requestedBytes
 
AZStd::atomic< size_t > m_requestedBytesPeak
 
const char * m_allocatorName
 

Detailed Description

Container for debug allocation records. This records can be thread safe or not depending on your needs. When you set the thread safe flag all functions will be thread safe unless explicitly noted.

IMPORTANT: If you enable isAllocationGuard (true), you will need to make sure every every has MemoryGuardSize() bytes at end. This is where the memory guard will be located. Failure to do so will cause failed memory stomps and possible memory corruption.

Member Enumeration Documentation

◆ Mode

Enumerator
RECORD_NO_RECORDS 

Never record any information.

RECORD_STACK_NEVER 

Never record stack traces. All other info is stored.

RECORD_STACK_IF_NO_FILE_LINE 

Record stack if fileName and lineNum are not available. (default)

RECORD_FULL 

Always record the full stack.

RECORD_MAX 

Must be last.

Constructor & Destructor Documentation

◆ AllocationRecords()

AZ::Debug::AllocationRecords::AllocationRecords ( unsigned char  stackRecordLevels,
bool  isMemoryGuard,
bool  isMarkUnallocatedMemory,
const char *  allocatorName 
)

IMPORTANT: if isAllocationGuard


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