public class ArenaMemoryAllocator extends Object implements MemoryAllocator
WritableMemory arena. The allocator maintains a high watermark that
is reset to zero when all outstanding allocations have been freed.| Modifier and Type | Method and Description |
|---|---|
Optional<ResourceHolder<org.apache.datasketches.memory.WritableMemory>> |
allocate(long size)
Allocates a block of memory of capacity .
|
long |
available()
Returns the number of bytes available for allocations.
|
long |
capacity()
Returns the number of bytes managed by this allocator.
|
static ArenaMemoryAllocator |
create(ByteBuffer buffer)
Creates an allocator based on a specific
ByteBuffer. |
static ArenaMemoryAllocator |
createOnHeap(int capacity)
Creates an allocator of a specific size using an on-heap
ByteBuffer. |
public static ArenaMemoryAllocator create(ByteBuffer buffer)
ByteBuffer. 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.public static ArenaMemoryAllocator createOnHeap(int capacity)
ByteBuffer.public Optional<ResourceHolder<org.apache.datasketches.memory.WritableMemory>> allocate(long size)
MemoryAllocatorResourceHolder.
The returned WritableMemory object will use little-endian byte order.allocate in interface MemoryAllocatorpublic long available()
MemoryAllocatorLong.MAX_VALUE if there is no inherent limit. This generally does not mean you can actually
allocate 9 exabytes.available in interface MemoryAllocatorpublic long capacity()
MemoryAllocatorMemoryAllocator.available().
May return Long.MAX_VALUE if there is no inherent limit. This generally does not mean you can actually
allocate 9 exabytes.capacity in interface MemoryAllocatorCopyright © 2011–2022 The Apache Software Foundation. All rights reserved.