#include <AllocatorManager.h>
Classes | |
| class | AllocatorLock |
| struct | AllocatorStats |
| struct | DumpInfo |
| struct | MemoryBreak |
Public Types | |
| typedef AZStd::function< void(IAllocator *allocator, size_t, size_t)> | OutOfMemoryCBType |
Public Member Functions | |
| AZStd::shared_ptr< AllocatorLock > | LockAllocators () |
| AZ_FORCE_INLINE int | GetNumAllocators () const |
| AZ_FORCE_INLINE IAllocator * | GetAllocator (int index) |
| void | GarbageCollect () |
| Calls all registered allocators garbage collect function. | |
| bool | AddOutOfMemoryListener (const OutOfMemoryCBType &cb) |
| Add out of memory listener. True if add was successful, false if listener was already added. | |
| void | RemoveOutOfMemoryListener () |
| Remove out of memory listener. | |
| void | SetDefaultTrackingMode (AZ::Debug::AllocationRecords::Mode mode) |
| Set default memory track mode for all allocators created after this point. | |
| AZ::Debug::AllocationRecords::Mode | GetDefaultTrackingMode () const |
| void | SetTrackingMode (AZ::Debug::AllocationRecords::Mode mode) |
| Set memory track mode for all allocators already created. | |
| void | SetAllocatorLeaking (bool allowLeaking) |
| Especially for great code and engines... | |
| void | EnterProfilingMode () |
| Enter or exit profiling mode; calls to Enter must be matched with calls to Exit. | |
| void | ExitProfilingMode () |
| void | SetDefaultProfilingState (bool newState) |
| bool | GetDefaultProfilingState () const |
| void | DumpAllocators () |
| Outputs allocator usage to the console, and also stores the values in m_dumpInfo for viewing in the crash dump. | |
| void | SetTrackingForAllocator (AZStd::string_view allocatorName, AZ::Debug::AllocationRecords::Mode recordMode) |
| bool | RemoveTrackingForAllocator (AZStd::string_view allocatorName) |
| void | GetAllocatorStats (size_t &usedBytes, size_t &reservedBytes, AZStd::vector< AllocatorStats > *outStats=nullptr) |
| void | SetMemoryBreak (int slot, const MemoryBreak &mb) |
| Installs a memory break on a specific slot (0 to MaxNumMemoryBreaks). Code will trigger and DebugBreak. | |
| void | ResetMemoryBreak (int slot=-1) |
| Reset a memory break. -1 all slots, otherwise (0 to MaxNumMemoryBreaks) | |
| void | RegisterAllocator (IAllocator *alloc) |
| void | UnRegisterAllocator (IAllocator *alloc) |
Static Public Member Functions | |
| static AllocatorManager & | Instance () |
| static bool | IsReady () |
| static void | Destroy () |
Static Public Attributes | |
| static const int | MaxNumMemoryBreaks = 5 |
Friends | |
| class | AllocatorBase |
| class | Debug::AllocationRecords |
Global allocation manager. It has access to all created allocators IAllocator interface. And control some global allocations. This manager is NOT thread safe, so all allocators should be created on the same thread (we can change that if needed, we just need a good reason).
| AZStd::shared_ptr< AllocatorLock > AZ::AllocatorManager::LockAllocators | ( | ) |
Locks the allocator manager so you can safely iterate over its contents. The manager will unlock when the returned object goes out of scope.
Allocators typically don't change during the lifetime of the app, but some systems may despawn or respawn allocators on a more frequent basis, e.g. when changing levels. So it is recommended to lock the manager whenever iterating over allocators.