public class AllocMemory extends MemoryMappedFile
The task of direct allocation was moved to this sub-class for performance reasons.
byteBuf_, capacityBytes_, memArray_, memReq_, nativeRawStartAddress_, objectBaseOffset_| Constructor and Description |
|---|
AllocMemory(long capacityBytes)
Constructor for allocate native memory.
|
AllocMemory(long capacityBytes,
MemoryRequest memReq)
Constructor for allocate native memory with MemoryRequest.
|
AllocMemory(NativeMemory origMem,
long copyToBytes,
long capacityBytes,
MemoryRequest memReq)
Constructor for allocate native memory, copy and clear.
|
AllocMemory(NativeMemory origMem,
long newCapacityBytes,
MemoryRequest memReq)
Constructor for reallocate native memory.
|
| Modifier and Type | Method and Description |
|---|---|
void |
freeMemory()
This frees this Memory only if it is required.
|
finalize, force, isLoaded, loadarray, asReadOnlyMemory, byteBuffer, clear, clear, clearBits, copy, copy, fill, fill, getAddress, getAndAddInt, getAndAddLong, getAndSetInt, getAndSetLong, getBoolean, getBooleanArray, getByte, getByteArray, getCapacity, getChar, getCharArray, getCumulativeOffset, getDouble, getDoubleArray, getFloat, getFloatArray, getInt, getIntArray, getLong, getLongArray, getMemoryRequest, getNativeMemory, getParent, getShort, getShortArray, hasArray, hasByteBuffer, isAllBitsClear, isAllBitsSet, isAllocated, isAnyBitsClear, isAnyBitsSet, isDirect, isReadOnly, putBoolean, putBooleanArray, putByte, putByteArray, putChar, putCharArray, putDouble, putDoubleArray, putFloat, putFloatArray, putInt, putIntArray, putLong, putLongArray, putShort, putShortArray, requiresFree, setBits, setMemoryRequest, toHexStringpublic AllocMemory(long capacityBytes)
Allocates and provides access to capacityBytes directly in native (off-heap) memory leveraging the Memory interface. The MemoryRequest callback is set to null.
capacityBytes - the size in bytes of the native memorypublic AllocMemory(long capacityBytes,
MemoryRequest memReq)
Allocates and provides access to capacityBytes directly in native (off-heap) memory leveraging the Memory interface.
capacityBytes - the size in bytes of the native memorymemReq - The MemoryRequest callbackpublic AllocMemory(NativeMemory origMem, long newCapacityBytes, MemoryRequest memReq)
Reallocates the given off-heap NativeMemory to a new a new native (off-heap) memory
location and copies the contents of the original given NativeMemory to the new location.
Any memory beyond the capacity of the original given NativeMemory will be uninitialized.
Dispose of this new memory by calling NativeMemory.freeMemory().
origMem - The original NativeMemory that needs to be reallocated and must not be null.
The OS is free to just expand the capacity of the current allocation at the same native
address, or reassign a completely different native address in which case the origMem will be
freed by the OS.
The origMem capacity will be set to zero and must not be used again.newCapacityBytes - the desired new capacity of the newly allocated memory in bytesmemReq - The MemoryRequest callback, which may be null.public AllocMemory(NativeMemory origMem, long copyToBytes, long capacityBytes, MemoryRequest memReq)
Allocate a new native (off-heap) memory with capacityBytes; copy the contents of origMem from zero to copyToBytes; clear the new memory from copyToBytes to capacityBytes.
origMem - The original NativeMemory, a portion of which will be copied to the
newly allocated Memory.
The reference must not be null.
This origMem is not modified in any way, may be reused and must be freed appropriately.copyToBytes - the upper limit of the region to be copied from origMem to the newly
allocated memory.capacityBytes - the desired new capacity of the newly allocated memory in bytes and the
upper limit of the region to be cleared.memReq - The MemoryRequest callback, which may be null.public void freeMemory()
NativeMemoryIt is always safe to call this method when you are done with this class.
freeMemory in class MemoryMappedFileCopyright © 2015–2016 Yahoo! Inc.. All rights reserved.