public class GridUnsafeMemory extends Object
| Constructor and Description |
|---|
GridUnsafeMemory(long total) |
| Modifier and Type | Method and Description |
|---|---|
long |
allocate(long size)
Allocates memory of given size in bytes.
|
long |
allocate(long size,
boolean init)
Allocates memory of given size in bytes.
|
long |
allocate(long size,
boolean init,
boolean reserved)
Allocates memory of given size in bytes.
|
long |
allocatedSize() |
long |
allocateSystem(long size,
boolean init)
Allocates memory of given size in bytes, adds to system memory counter.
|
boolean |
casInt(long ptr,
int exp,
int v) |
boolean |
casLong(long ptr,
long exp,
long v) |
static boolean |
compare(long ptr,
byte[] bytes)
Compares memory.
|
static boolean |
compare(long ptr,
byte[] bytes,
int bytesOff,
int len)
Compares memory.
|
static boolean |
compare(long ptr1,
long ptr2,
int size) |
void |
copyMemory(long srcPtr,
long destPtr,
long len)
Copy memory.
|
void |
fill(long ptr,
long size,
byte b) |
long |
freeSize() |
IgniteBiTuple<byte[],Byte> |
get(long ptr)
Get value stored in offheap along with a value type.
|
void |
listen(GridOffHeapEventListener lsnr)
Sets event listener.
|
long |
putOffHeap(long ptr,
byte[] val,
byte type)
Stores value to the specified memory location.
|
byte |
readByte(long ptr) |
byte[] |
readBytes(long ptr,
byte[] arr) |
byte[] |
readBytes(long ptr,
byte[] arr,
int off,
int len) |
byte[] |
readBytes(long ptr,
int cnt) |
byte |
readByteVolatile(long ptr) |
double |
readDouble(long ptr) |
float |
readFloat(long ptr) |
int |
readInt(long ptr) |
int |
readIntVolatile(long ptr) |
long |
readLong(long ptr) |
long |
readLongVolatile(long ptr) |
short |
readShort(long ptr) |
void |
release(long ptr,
long size)
Releases memory at the given address.
|
void |
releaseSystem(long ptr,
long size)
Releases memory allocated by
allocateSystem(long, boolean). |
void |
removeOffHeap(long ptr)
Releases off-heap memory allocated by
putOffHeap(long, byte[], byte) method. |
boolean |
reserve(long size)
Reserves memory.
|
long |
systemAllocatedSize() |
String |
toString() |
long |
totalSize() |
boolean |
unlimited()
Checks if direct memory allocation is limited to some value.
|
void |
writeByte(long ptr,
byte v) |
void |
writeBytes(long ptr,
byte[] arr)
Writes byte array into memory location.
|
void |
writeBytes(long ptr,
byte[] arr,
int off,
int len)
Writes part of byte array into memory location.
|
void |
writeByteVolatile(long ptr,
byte v) |
void |
writeDouble(long ptr,
double v) |
void |
writeFloat(long ptr,
float v) |
void |
writeInt(long ptr,
int v) |
void |
writeIntVolatile(long ptr,
int v) |
void |
writeLong(long ptr,
long v) |
void |
writeLongVolatile(long ptr,
long v) |
void |
writeShort(long ptr,
short v) |
public GridUnsafeMemory(long total)
total - Total size, 0 for unlimited.public void listen(GridOffHeapEventListener lsnr)
lsnr - Event listener.public boolean reserve(long size)
size - Size to reserve.True if memory is under allowed size, false otherwise.public long allocate(long size)
throws GridOffHeapOutOfMemoryException
size - Size of allocated block.GridOffHeapOutOfMemoryException - If Memory could not be allocated.public long allocate(long size,
boolean init)
throws GridOffHeapOutOfMemoryException
size - Size of allocated block.init - Flag to zero-out the initialized memory or not.GridOffHeapOutOfMemoryException - If Memory could not be allocated.public long allocate(long size,
boolean init,
boolean reserved)
throws GridOffHeapOutOfMemoryException
size - Size of allocated block.init - Flag to zero-out the initialized memory or not.reserved - Flag indicating that memory being allocated was reserved before.GridOffHeapOutOfMemoryException - If memory could not be allocated.public long allocateSystem(long size,
boolean init)
throws GridOffHeapOutOfMemoryException
size - Size of allocated block.init - Whether or not allocated block is zeroed upon return.GridOffHeapOutOfMemoryException - If memory could not be allocated.public void fill(long ptr,
long size,
byte b)
ptr - Pointer.size - Count of long values to fill.b - Value.public void release(long ptr,
long size)
ptr - Pointer to memory.size - Memory region size.public void releaseSystem(long ptr,
long size)
allocateSystem(long, boolean).ptr - Address of memory block to deallocate.size - Size of allocated block.public long readLong(long ptr)
ptr - Pointer.public void writeLong(long ptr,
long v)
ptr - Pointer.v - Long value.public long readLongVolatile(long ptr)
ptr - Pointer.public void writeLongVolatile(long ptr,
long v)
ptr - Pointer.v - Long value.public boolean casLong(long ptr,
long exp,
long v)
ptr - Pointer.exp - Expected.v - New value.true If operation succeeded.public int readInt(long ptr)
ptr - Pointer.public void writeInt(long ptr,
int v)
ptr - Pointer.v - Integer value.public int readIntVolatile(long ptr)
ptr - Pointer.public void writeIntVolatile(long ptr,
int v)
ptr - Pointer.v - Integer value.public boolean casInt(long ptr,
int exp,
int v)
ptr - Pointer.exp - Expected.v - New value.true If operation succeeded.public float readFloat(long ptr)
ptr - Pointer.public void writeFloat(long ptr,
float v)
ptr - Pointer.v - Value.public double readDouble(long ptr)
ptr - Pointer.public void writeDouble(long ptr,
double v)
ptr - Pointer.v - Value.public short readShort(long ptr)
ptr - Pointer.public void writeShort(long ptr,
short v)
ptr - Pointer.v - Short value.public byte readByte(long ptr)
ptr - Pointer.public byte readByteVolatile(long ptr)
ptr - Pointer.public void writeByte(long ptr,
byte v)
ptr - Pointer.v - Integer value.public void writeByteVolatile(long ptr,
byte v)
ptr - Pointer.v - Integer value.public long putOffHeap(long ptr,
byte[] val,
byte type)
0, then will
allocate required space. If size of allocated space is not enough to hold given values, will
reallocate memory.ptr - Optional pointer to allocated memory. First 4 bytes in allocated region must contain
size of allocated chunk.val - Value to store.type - Value type.public void removeOffHeap(long ptr)
putOffHeap(long, byte[], byte) method.ptr - Optional pointer returned by putOffHeap(long, byte[], byte).public IgniteBiTuple<byte[],Byte> get(long ptr)
ptr - Pointer to read.public static boolean compare(long ptr1,
long ptr2,
int size)
ptr1 - First pointer.ptr2 - Second pointer.size - Memory size.True if equals.public static boolean compare(long ptr,
byte[] bytes)
ptr - Pointer.bytes - Bytes to compare.True if equals.public static boolean compare(long ptr,
byte[] bytes,
int bytesOff,
int len)
ptr - Pointer.bytes - Bytes to compare.bytesOff - Offset in the bytes array.len - Count of compared bytes.True if equals.public byte[] readBytes(long ptr,
int cnt)
ptr - Pointer.cnt - Count.public byte[] readBytes(long ptr,
byte[] arr)
ptr - Pointer.arr - Array.public byte[] readBytes(long ptr,
byte[] arr,
int off,
int len)
ptr - Pointer.arr - Array.off - Offset.len - Length.public void writeBytes(long ptr,
byte[] arr)
ptr - Pointer.arr - Array.public void writeBytes(long ptr,
byte[] arr,
int off,
int len)
ptr - Pointer.arr - Array.off - Offset.len - Length.public void copyMemory(long srcPtr,
long destPtr,
long len)
srcPtr - Source pointer.destPtr - Destination pointer.len - Length in bytes.public boolean unlimited()
True if memory allocation is limited.public long totalSize()
public long freeSize()
public long allocatedSize()
public long systemAllocatedSize()
allocateSystem(long, boolean).
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.11.1 Release Date : December 20 2021