private long freeMemory() {
        updatePeakMemoryUsed();
        long memoryFreed = 0;
        for (MemoryBlock block : allocatedPages) {
            memoryFreed += block.size();
            freePage(block);
        }
        allocatedPages.clear();
        currentPage = null;
        pageCursor = 0;
        return memoryFreed;
    }
Free this sorter's data pages.

@return the number of bytes freed.
indexr-query-opt/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java