public synchronized void releaseMemory(long size, long taskAttemptId) {
        long cur = memoryForTask.get(taskAttemptId);
        cur -= size;
        totalUsedMemory -= size;
        Preconditions.checkState(cur >= 0);
        Preconditions.checkState(totalUsedMemory >= 0);
        if (cur <= 0) {
            memoryForTask.remove(taskAttemptId);
        } else {
            memoryForTask.put(taskAttemptId, cur);
        }
    }
Allocates memory for use by Unsafe/Tungsten code.
indexr-query-opt/src/main/java/org/apache/spark/memory/MemoryManager.java