public class UnpooledOffHeapMemoryAllocator extends Object implements OffHeapMemoryAllocator
Unsafe
.Constructor and Description |
---|
UnpooledOffHeapMemoryAllocator() |
Modifier and Type | Method and Description |
---|---|
long |
allocate(long memoryLength)
Allocates a new chunk of memory sized to the given length.
|
void |
deallocate(long memoryAddress,
long size)
Deallocates the memory at the given address assuming a given size.
|
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.
|
long |
getAllocatedAmount() |
static long |
offHeapEntrySize(boolean evictionEnabled,
boolean writeMetadataSize,
int keySize,
int valueSize)
|
static long |
offHeapEntrySize(boolean evictionEnabled,
boolean writeMetadataSize,
int keySize,
int valueSize,
int metadataSize,
int internalMetadataSize)
It returns the off-heap size of an entry without alignment.
|
public long allocate(long memoryLength)
OffHeapMemoryAllocator
allocate
in interface OffHeapMemoryAllocator
memoryLength
- the size of memory to allocatepublic void deallocate(long memoryAddress, long size)
OffHeapMemoryAllocator
deallocate
in interface OffHeapMemoryAllocator
memoryAddress
- the address to deallocate fromsize
- the total sizepublic long getAllocatedAmount()
getAllocatedAmount
in interface OffHeapMemoryAllocator
public static long estimateSizeOverhead(long size)
size
- the desired size of the allocationpublic static long offHeapEntrySize(boolean evictionEnabled, boolean writeMetadataSize, int keySize, int valueSize)
public static long offHeapEntrySize(boolean evictionEnabled, boolean writeMetadataSize, int keySize, int valueSize, int metadataSize, int internalMetadataSize)
If alignment is required, use estimateSizeOverhead(offHeapEntrySize(...))
. See estimateSizeOverhead(long)
,
evictionEnabled
- Set to true
if eviction is enabled.writeMetadataSize
- Set to true
if the Metadata
has versioning or
it is a custom implementation.keySize
- The key size.valueSize
- The value size.metadataSize
- The Metadata
size. If writeMetadataSize
is
false, this parameter must include the size of mortal/transient entries (2 or 4
longs).internalMetadataSize
- The PrivateMetadata
size.Copyright © 2021 JBoss by Red Hat. All rights reserved.