关注 spark技术分享,
撸spark源码 玩spark最佳实践

MemoryConsumer

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.

spill Method

Caution
FIXME

Memory Allocated — used Registry

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

Deallocate MemoryBlock — freePage Method

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

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.

Acquiring Memory — acquireMemory Method

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

throwOom Internal Method

throwOom…​FIXME

Note
throwOom is used when MemoryConsumer is requested to allocateArray and allocatePage.

allocatePage Method

allocatePage…​FIXME

Note
allocatePage is used when…​FIXME
赞(0) 打赏
未经允许不得转载:spark技术分享 » MemoryConsumer
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏