In the secondary allocation routine, the StatsAllocated stat is
increased by BlockSize. However, in the deallocate routine, the
stat subtract uses CommitSize. CommitSize can be bigger than BlockSize
so this can lead to a negative calculated stat. Since the stats
are not guaranteed to be completely accurate, just add CommitSize
during allocation.
Reviewed By: Chia-hungDuan
Differential Revision: https://reviews.llvm.org/D150169
if (FillContents && !Zeroed)
memset(Ptr, FillContents == ZeroFill ? 0 : PatternFillByte,
BlockEnd - PtrInt);
- const uptr BlockSize = BlockEnd - HInt;
{
ScopedLock L(Mutex);
InUseBlocks.push_back(H);
- AllocatedBytes += BlockSize;
+ AllocatedBytes += H->CommitSize;
NumberOfAllocs++;
- Stats.add(StatAllocated, BlockSize);
+ Stats.add(StatAllocated, H->CommitSize);
Stats.add(StatMapped, H->MemMap.getCapacity());
}
return Ptr;