Package org.infinispan.container.offheap
Class UnpooledOffHeapMemoryAllocator
- java.lang.Object
-
- org.infinispan.container.offheap.UnpooledOffHeapMemoryAllocator
-
- All Implemented Interfaces:
OffHeapMemoryAllocator
public class UnpooledOffHeapMemoryAllocator extends Object implements OffHeapMemoryAllocator
Memory allocator that just allocates memory directly usingUnsafe.- Since:
- 9.0
- Author:
- wburns
-
-
Constructor Summary
Constructors Constructor Description UnpooledOffHeapMemoryAllocator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longallocate(long memoryLength)Allocates a new chunk of memory sized to the given length.voiddeallocate(long memoryAddress, long size)Deallocates the memory at the given address assuming a given size.static longestimateSizeOverhead(long size)Tries to estimate overhead of the allocation by first adding 8 to account for underlying allocator housekeeping and then rounds up to nearest power of 16 to account for 16 byte alignment.longgetAllocatedAmount()
-
-
-
Method Detail
-
allocate
public long allocate(long memoryLength)
Description copied from interface:OffHeapMemoryAllocatorAllocates a new chunk of memory sized to the given length.- Specified by:
allocatein interfaceOffHeapMemoryAllocator- Parameters:
memoryLength- the size of memory to allocate- Returns:
- the memory address where the memory resides
-
deallocate
public void deallocate(long memoryAddress, long size)Description copied from interface:OffHeapMemoryAllocatorDeallocates the memory at the given address assuming a given size. This size is the size that was provided to allocate.- Specified by:
deallocatein interfaceOffHeapMemoryAllocator- Parameters:
memoryAddress- the address to deallocate fromsize- the total size
-
getAllocatedAmount
public long getAllocatedAmount()
- Specified by:
getAllocatedAmountin interfaceOffHeapMemoryAllocator
-
estimateSizeOverhead
public static long estimateSizeOverhead(long size)
Tries to estimate overhead of the allocation by first adding 8 to account for underlying allocator housekeeping and then rounds up to nearest power of 16 to account for 16 byte alignment.- Parameters:
size- the desired size of the allocation- Returns:
- the resulting size taking into account various overheads
-
-