MemoryConsumer

MemoryConsumer is the contract for memory consumers of TaskMemoryManager with support for spilling.

A MemoryConsumer basically tracks how much memory is allocated.

Creating a MemoryConsumer requires a TaskMemoryManager with optional pageSize and a MemoryMode.

Note
If not specified, pageSize defaults to TaskMemoryManager.pageSizeBytes and ON_HEAP memory mode.

MemoryConsumer Contract

Caution
FIXME the contract

Memory Allocated (used Registry)

used is the amount of memory in use (i.e. allocated) by the MemoryConsumer.

spill method

abstract long spill(long size, MemoryConsumer trigger) throws IOException

Deallocate LongArray (freeArray method)

void freeArray(LongArray array)

Deallocate MemoryBlock (freePage method)

protected void freePage(MemoryBlock page)

freePage is a protected method to deallocate the MemoryBlock.

Internally, it decrements used registry by the size of page and frees the page.

Allocate LongArray (allocateArray method)

LongArray allocateArray(long size)

allocateArray allocates LongArray of size length.

Internally, it allocates a page for the requested size. The size is recorded in the internal used counter.

However, if it was not possible to allocate the size memory, it shows the current memory usage and a OutOfMemoryError is thrown.

Unable to acquire [required] bytes of memory, got [got]

Acquiring Memory (acquireMemory method)

long acquireMemory(long size)

acquireMemory acquires execution memory of size size. The memory is recorded in used registry.

results matching ""

    No results matching ""