MemoryManager is the base of memory managers that manage shared memory for task execution and block storage.
package org.apache.spark.memory
abstract class MemoryManager(...) {
// only required methods that have no implementation
// the others follow
def acquireExecutionMemory(
numBytes: Long,
taskAttemptId: Long,
memoryMode: MemoryMode): Long
def acquireStorageMemory(blockId: BlockId, numBytes: Long, memoryMode: MemoryMode): Boolean
def acquireUnrollMemory(blockId: BlockId, numBytes: Long, memoryMode: MemoryMode): Boolean
def maxOffHeapStorageMemory: Long
def maxOnHeapStorageMemory: Long
}|
Note
|
MemoryManager is a private[spark] contract.
|
| Method | Description |
|---|---|
|
Used exclusively when |
|
|
|
Used exclusively when |
|
|
|
|
|
Note
|
MemoryManager is a Scala abstract class and cannot be created directly, but only as one of the implementations.
|
Execution memory is used for computation in shuffles, joins, sorts and aggregations.
Storage memory is used for caching and propagating internal data across the nodes in a cluster.
| MemoryManager | Description |
|---|---|
| Name | Description | ||
|---|---|---|---|
|
Used when…FIXME |
||
|
Used when…FIXME |
||
|
Used when…FIXME |
||
|
Used when…FIXME
|
MemoryManager takes the following when created:
MemoryManager initializes the internal registries and counters.
|
Note
|
MemoryManager is a Scala abstract class and cannot be created directly, but only as one of the implementations.
|
releaseExecutionMemory(
numBytes: Long,
taskAttemptId: Long,
memoryMode: MemoryMode): UnitreleaseExecutionMemory…FIXME
|
Note
|
releaseExecutionMemory is used when TaskMemoryManager is requested to releaseExecutionMemory and cleanUpAllAllocatedMemory
|
releaseAllExecutionMemoryForTask(taskAttemptId: Long): LongreleaseAllExecutionMemoryForTask…FIXME
|
Note
|
releaseAllExecutionMemoryForTask is used exclusively when TaskRunner is requested to run (and cleans up after itself).
|
tungstenMemoryMode: MemoryModetungstenMemoryMode returns OFF_HEAP only when the following are all met:
-
spark.memory.offHeap.enabled configuration property is enabled (it is not by default)
-
spark.memory.offHeap.size configuration property is greater than
0(it is0by default) -
JVM supports unaligned memory access (aka unaligned Unsafe, i.e.
sun.misc.Unsafepackage is available and the underlying system has unaligned-access capability)
Otherwise, tungstenMemoryMode returns ON_HEAP.
|
Note
|
Given that spark.memory.offHeap.enabled configuration property is disabled (false) by default and spark.memory.offHeap.size configuration property is 0 by default, Spark seems to encourage using Tungsten memory allocated on the JVM heap (ON_HEAP).
|
|
Note
|
tungstenMemoryMode is a Scala final val and cannot be changed by custom MemoryManagers.
|
|
Note
|
|