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.
|
abstract long spill(long size, MemoryConsumer trigger)
throws IOException
Caution
|
FIXME |
used
is the amount of memory in use (i.e. allocated) by the MemoryConsumer
.
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.
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]
long acquireMemory(long size)
acquireMemory
acquires execution memory of size
size. The memory is recorded in used registry.
void throwOom(final MemoryBlock page, final long required)
throwOom
…FIXME
Note
|
throwOom is used when MemoryConsumer is requested to allocateArray and allocatePage.
|