MemoryConsumer¶
MemoryConsumer
is an abstraction of memory consumers (of TaskMemoryManager) that support spilling.
MemoryConsumer
s correspond to individual operators and data structures within a task. TaskMemoryManager
receives memory allocation requests from MemoryConsumer
s and issues callbacks to consumers in order to trigger spilling when running low on memory.
A MemoryConsumer
basically tracks how much memory is allocated.
Contract¶
Spilling¶
void spill() // (1)
long spill(
long size,
MemoryConsumer trigger)
- Uses
MAX_VALUE
for the size and thisMemoryConsumer
Used when:
TaskMemoryManager
is requested to acquire execution memory (and trySpillAndAcquire)ShuffleExternalSorter
is requested to growPointerArrayIfNecessary, insertRecordUnsafeExternalSorter
is requested to createWithExistingInMemorySorter, growPointerArrayIfNecessary, insertRecord, merge
Implementations¶
Creating Instance¶
MemoryConsumer
takes the following to be created:
- TaskMemoryManager
- Page Size
-
MemoryMode
(ON_HEAP
orOFF_HEAP
)
Abstract Class
MemoryConsumer
is an abstract class and cannot be created directly. It is created indirectly for the concrete MemoryConsumers.