public long cleanUpAllAllocatedMemory() {
        synchronized (this) {
            Arrays.fill(pageTable, null);
            for (MemoryConsumer c : consumers) {
                if (c != null && c.getUsed() > 0) {
                    // In case of failed task, it's normal to see leaked memory
                    logger.warn("leak " + Utils.bytesToString(c.getUsed()) + " memory from " + c);
                }
            }
            consumers.clear();
        }

        for (MemoryBlock page : pageTable) {
            if (page != null) {
                memoryManager.tungstenMemoryAllocator().free(page);
            }
        }
        Arrays.fill(pageTable, null);

        return memoryManager.releaseAllMemoryForTask(taskAttemptId);
    }
Clean up all allocated memory and pages. Returns the number of bytes freed. A non-zero return
value can be used to detect memory leaks.
indexr-query-opt/src/main/java/org/apache/spark/memory/TaskMemoryManager.java