@@ -594,7 +594,7 @@ void *MapAllocator<Config>::allocate(const Options &Options, uptr Size,
594594 ScopedLock L (Mutex);
595595 InUseBlocks.push_back (H);
596596 AllocatedBytes += H->CommitSize ;
597- FragmentedBytes += reinterpret_cast <uptr>(H ) - H->CommitBase ;
597+ FragmentedBytes += H-> MemMap . getCapacity ( ) - H->CommitSize ;
598598 NumberOfAllocs++;
599599 Stats.add (StatAllocated, H->CommitSize );
600600 Stats.add (StatMapped, H->MemMap .getCapacity ());
@@ -668,7 +668,7 @@ void *MapAllocator<Config>::allocate(const Options &Options, uptr Size,
668668 ScopedLock L (Mutex);
669669 InUseBlocks.push_back (H);
670670 AllocatedBytes += CommitSize;
671- FragmentedBytes += reinterpret_cast <uptr>(H ) - H-> CommitBase ;
671+ FragmentedBytes += H-> MemMap . getCapacity ( ) - CommitSize ;
672672 if (LargestSize < CommitSize)
673673 LargestSize = CommitSize;
674674 NumberOfAllocs++;
@@ -687,7 +687,7 @@ void MapAllocator<Config>::deallocate(const Options &Options, void *Ptr)
687687 ScopedLock L (Mutex);
688688 InUseBlocks.remove (H);
689689 FreedBytes += CommitSize;
690- FragmentedBytes -= reinterpret_cast <uptr>(H ) - H-> CommitBase ;
690+ FragmentedBytes -= H-> MemMap . getCapacity ( ) - CommitSize ;
691691 NumberOfFrees++;
692692 Stats.sub (StatAllocated, CommitSize);
693693 Stats.sub (StatMapped, H->MemMap .getCapacity ());
0 commit comments