Browse Source

Update maxUsed at the correct moment.

Rika Ichinose 1 month ago
parent
commit
49805e0361
1 changed files with 5 additions and 5 deletions
  1. 5 5
      rtl/inc/heap.inc

+ 5 - 5
rtl/inc/heap.inc

@@ -1116,15 +1116,15 @@ type
       size := vSizeFlags and VarSizeMask;
     end;
 
-    { Update maxUsed regardless. }
-    statv := used + gs.hugeUsed;
-    if statv > maxUsed then
-      maxUsed := statv;
-
     if isArena then
       inc(pVarHeader(result)[-1].ch.h, FixedArenaFlag) { Arenas aren’t counted in “used” directly. }
     else
       inc(used, size);
+
+    { Update maxUsed regardless. }
+    statv := used + gs.hugeUsed;
+    if statv > maxUsed then
+      maxUsed := statv;
   end;
 
   function HeapInc.ThreadState.FreeVar(p: pointer): SizeUint;