Class ArenaMemoryAllocator
java.lang.Object
org.apache.druid.frame.allocation.ArenaMemoryAllocator
- All Implemented Interfaces:
MemoryAllocator
Allocator that uses a reusable
WritableMemory arena. The allocator maintains a high watermark that
is reset to zero when all outstanding allocations have been freed.-
Method Summary
Modifier and TypeMethodDescriptionOptional<ResourceHolder<org.apache.datasketches.memory.WritableMemory>>allocate(long size) Allocates a block of memory of capacity .longReturns the number of bytes available for allocations.longcapacity()Returns the number of bytes managed by this allocator.static ArenaMemoryAllocatorcreate(ByteBuffer buffer) Creates an allocator based on a specificByteBuffer.static ArenaMemoryAllocatorcreateOnHeap(int capacity) Creates an allocator of a specific size using an on-heapByteBuffer.
-
Method Details
-
create
Creates an allocator based on a specificByteBuffer. The buffer is never freed, so to ensure proper cleanup when the allocator is discarded, this buffer must be on-heap (so it can be garbage collected) rather than off-heap. -
createOnHeap
Creates an allocator of a specific size using an on-heapByteBuffer. -
allocate
Description copied from interface:MemoryAllocatorAllocates a block of memory of capacity . Returns empty if no more memory is available. The memory can be freed by closing the returnedResourceHolder. The returned WritableMemory object will use little-endian byte order.- Specified by:
allocatein interfaceMemoryAllocator
-
available
public long available()Description copied from interface:MemoryAllocatorReturns the number of bytes available for allocations. May returnLong.MAX_VALUEif there is no inherent limit. This generally does not mean you can actually allocate 9 exabytes.- Specified by:
availablein interfaceMemoryAllocator
-
capacity
public long capacity()Description copied from interface:MemoryAllocatorReturns the number of bytes managed by this allocator. When no memory has been allocated yet, this is identical toMemoryAllocator.available(). May returnLong.MAX_VALUEif there is no inherent limit. This generally does not mean you can actually allocate 9 exabytes.- Specified by:
capacityin interfaceMemoryAllocator
-