diff --git a/spark/src/main/java/org/apache/spark/shuffle/sort/CometShuffleExternalSorter.java b/spark/src/main/java/org/apache/spark/shuffle/sort/CometShuffleExternalSorter.java index aa806e2e81..ed0cfa9631 100644 --- a/spark/src/main/java/org/apache/spark/shuffle/sort/CometShuffleExternalSorter.java +++ b/spark/src/main/java/org/apache/spark/shuffle/sort/CometShuffleExternalSorter.java @@ -257,6 +257,7 @@ private long getMemoryUsage() { for (SpillSorter sorter : spillingSorters) { totalPageSize += sorter.getMemoryUsage(); } + totalPageSize += activeSpillSorter.getMemoryUsage(); return totalPageSize; } @@ -274,6 +275,7 @@ public long getPeakMemoryUsedBytes() { } private long freeMemory() { + updatePeakMemoryUsed(); long memoryFreed = 0; if (isAsync) { for (SpillSorter sorter : spillingSorters) {