Interface MemoryAllocator
-
- All Known Implementing Classes:
ArenaMemoryAllocator,HeapMemoryAllocator
public interface MemoryAllocatorAllocator of WritableMemory. Not thread safe.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Optional<ResourceHolder<org.apache.datasketches.memory.WritableMemory>>allocate(long size)Allocates a block of memory of capacity {@param size}.longavailable()Returns the number of bytes available for allocations.longcapacity()Returns the number of bytes managed by this allocator.
-
-
-
Method Detail
-
allocate
Optional<ResourceHolder<org.apache.datasketches.memory.WritableMemory>> allocate(long size)
Allocates a block of memory of capacity {@param size}. 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.
-
available
long available()
Returns 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.
-
capacity
long capacity()
Returns the number of bytes managed by this allocator. When no memory has been allocated yet, this is identical toavailable(). May returnLong.MAX_VALUEif there is no inherent limit. This generally does not mean you can actually allocate 9 exabytes.
-
-