diff --git a/Code/Framework/AzCore/AzCore/Memory/HphaSchema.cpp b/Code/Framework/AzCore/AzCore/Memory/HphaSchema.cpp index 6891eb4248..5e0e3e2de8 100644 --- a/Code/Framework/AzCore/AzCore/Memory/HphaSchema.cpp +++ b/Code/Framework/AzCore/AzCore/Memory/HphaSchema.cpp @@ -719,8 +719,12 @@ namespace AZ { #endif // DEBUG_ALLOCATOR - size_t mTotalAllocatedSizeBuckets = 0; - size_t mTotalCapacitySizeBuckets = 0; + // Bucket-dependent counters need to atomic since the locks that protect bucket allocations are per bucket + // So multiple threads could be updating these counters + AZStd::atomic mTotalAllocatedSizeBuckets = 0; + AZStd::atomic mTotalCapacitySizeBuckets = 0; + // In the case of tree allocations, there is a lock on the tree, so these counters are protected from multiple + // threads through that lock size_t mTotalAllocatedSizeTree = 0; size_t mTotalCapacitySizeTree = 0; public: