public void cleanupResources() {
        synchronized (this) {
            deleteSpillFiles();
            freeMemory();
            if (inMemSorter != null) {
                inMemSorter.free();
                inMemSorter = null;
            }
        }
    }
Frees this sorter's in-memory data structures and cleans up its spill files.
indexr-query-opt/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeExternalSorter.java