protected MemoryBlock allocatePage(long required) {
        MemoryBlock page = taskMemoryManager.allocatePage(Math.max(pageSize, required), this);
        if (page == null || page.size() < required) {
            long got = 0;
            if (page != null) {
                got = page.size();
                taskMemoryManager.freePage(page, this);
            }
            taskMemoryManager.showMemoryUsage();
            throw new OutOfMemoryError("Unable to acquire " + required + " bytes of memory, got " + got);
        }
        used += page.size();
        return page;
    }
Allocate a memory block with at least `required` bytes.

Throws IOException if there is not enough memory.
indexr-query-opt/src/main/java/org/apache/spark/memory/MemoryConsumer.java