public synchronized long acquireMemory(long required, long taskAttemptId) {
        long cur = memoryForTask.get(taskAttemptId);
        long got;
        if (totalUsedMemory + required > maxOffHeapMemory) {
            got = maxOffHeapMemory - totalUsedMemory;
        } else {
            got = required;
        }
        totalUsedMemory += got;
        memoryForTask.put(taskAttemptId, cur + got);
        return got;
    }
Allocates memory for use by Unsafe/Tungsten code.
indexr-query-opt/src/main/java/org/apache/spark/memory/MemoryManager.java