Class PlatformMemoryUtils
- java.lang.Object
-
- org.apache.ignite.internal.processors.platform.memory.PlatformMemoryUtils
-
public class PlatformMemoryUtils extends Object
Utility classes for memory management.
-
-
Field Summary
Fields Modifier and Type Field Description static intFLAG_ACQUIREDFlag: whether this pooled memory chunk is acquired.static intFLAG_EXTFlag: external.static intFLAG_POOLEDFlag: pooled.static intMEM_HDR_LENMemory chunk header length.static intMEM_HDR_OFF_CAPOffset: capacity.static intMEM_HDR_OFF_FLAGSOffset: flags.static intMEM_HDR_OFF_LENOffset: length.static intPOOL_HDR_LENHeader length.static intPOOL_HDR_OFF_MEM_1Pool header offset: first memory chunk.static intPOOL_HDR_OFF_MEM_2Pool header offset: second memory chunk.static intPOOL_HDR_OFF_MEM_3Pool header offset: third memory chunk.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longallocatePool()Allocate pool memory.static longallocatePooled(long poolPtr, int cap)Allocate pooled memory chunk.static longallocateUnpooled(int cap)Allocate unpooled memory chunk.static intcapacity(long memPtr)Gets capacity for the given memory chunk.static voidcapacity(long memPtr, int cap)Sets capacity for the given memory chunk.static longdata(long memPtr)Gets data pointer for the given memory chunk.static intflags(long memPtr)Gets flags for the given memory chunk.static voidflags(long memPtr, int flags)Sets flags for the given memory chunk.static booleanisAcquired(int flags)Check whether flags denote pooled and acquired memory chunk.static booleanisAcquired(long memPtr)Check whether this memory chunk is pooled and acquired.static booleanisExternal(int flags)Check whether flags denote that this memory chunk is external.static booleanisExternal(long memPtr)Check whether this memory chunk is external.static booleanisPooled(int flags)Check whether flags denote pooled memory chunk.static booleanisPooled(long memPtr)Check whether this memory chunk is pooled.static intlength(long memPtr)Gets length for the given memory chunk.static voidlength(long memPtr, int len)Sets length for the given memory chunk.static voidreallocate(long memPtr, int cap)Reallocate arbitrary memory chunk.static voidreallocatePooled(long memPtr, int cap)Reallocate pooled memory chunk.static voidreallocateUnpooled(long memPtr, int cap)Reallocate unpooled memory chunk.static voidreleasePool(long poolPtr)Release pool memory.static voidreleasePooled(long memPtr)Release pooled memory chunk.static voidreleaseUnpooled(long memPtr)Release unpooled memory chunk.
-
-
-
Field Detail
-
POOL_HDR_LEN
public static final int POOL_HDR_LEN
Header length.- See Also:
- Constant Field Values
-
POOL_HDR_OFF_MEM_1
public static final int POOL_HDR_OFF_MEM_1
Pool header offset: first memory chunk.- See Also:
- Constant Field Values
-
POOL_HDR_OFF_MEM_2
public static final int POOL_HDR_OFF_MEM_2
Pool header offset: second memory chunk.- See Also:
- Constant Field Values
-
POOL_HDR_OFF_MEM_3
public static final int POOL_HDR_OFF_MEM_3
Pool header offset: third memory chunk.- See Also:
- Constant Field Values
-
MEM_HDR_LEN
public static final int MEM_HDR_LEN
Memory chunk header length.- See Also:
- Constant Field Values
-
MEM_HDR_OFF_CAP
public static final int MEM_HDR_OFF_CAP
Offset: capacity.- See Also:
- Constant Field Values
-
MEM_HDR_OFF_LEN
public static final int MEM_HDR_OFF_LEN
Offset: length.- See Also:
- Constant Field Values
-
MEM_HDR_OFF_FLAGS
public static final int MEM_HDR_OFF_FLAGS
Offset: flags.- See Also:
- Constant Field Values
-
FLAG_EXT
public static final int FLAG_EXT
Flag: external.- See Also:
- Constant Field Values
-
FLAG_POOLED
public static final int FLAG_POOLED
Flag: pooled.- See Also:
- Constant Field Values
-
FLAG_ACQUIRED
public static final int FLAG_ACQUIRED
Flag: whether this pooled memory chunk is acquired.- See Also:
- Constant Field Values
-
-
Method Detail
-
data
public static long data(long memPtr)
Gets data pointer for the given memory chunk.- Parameters:
memPtr- Memory pointer.- Returns:
- Data pointer.
-
capacity
public static int capacity(long memPtr)
Gets capacity for the given memory chunk.- Parameters:
memPtr- Memory pointer.- Returns:
- Capacity.
-
capacity
public static void capacity(long memPtr, int cap)Sets capacity for the given memory chunk.- Parameters:
memPtr- Memory pointer.cap- Capacity.
-
length
public static int length(long memPtr)
Gets length for the given memory chunk.- Parameters:
memPtr- Memory pointer.- Returns:
- Length.
-
length
public static void length(long memPtr, int len)Sets length for the given memory chunk.- Parameters:
memPtr- Memory pointer.len- Length.
-
flags
public static int flags(long memPtr)
Gets flags for the given memory chunk.- Parameters:
memPtr- Memory pointer.- Returns:
- Flags.
-
flags
public static void flags(long memPtr, int flags)Sets flags for the given memory chunk.- Parameters:
memPtr- Memory pointer.flags- Flags.
-
isExternal
public static boolean isExternal(long memPtr)
Check whether this memory chunk is external.- Parameters:
memPtr- Memory pointer.- Returns:
Trueif owned by native platform.
-
isExternal
public static boolean isExternal(int flags)
Check whether flags denote that this memory chunk is external.- Parameters:
flags- Flags.- Returns:
Trueif owned by native platform.
-
isPooled
public static boolean isPooled(long memPtr)
Check whether this memory chunk is pooled.- Parameters:
memPtr- Memory pointer.- Returns:
Trueif pooled.
-
isPooled
public static boolean isPooled(int flags)
Check whether flags denote pooled memory chunk.- Parameters:
flags- Flags.- Returns:
Trueif pooled.
-
isAcquired
public static boolean isAcquired(long memPtr)
Check whether this memory chunk is pooled and acquired.- Parameters:
memPtr- Memory pointer.- Returns:
Trueif pooled and acquired.
-
isAcquired
public static boolean isAcquired(int flags)
Check whether flags denote pooled and acquired memory chunk.- Parameters:
flags- Flags.- Returns:
Trueif acquired.
-
allocateUnpooled
public static long allocateUnpooled(int cap)
Allocate unpooled memory chunk.- Parameters:
cap- Minimum capacity.- Returns:
- New memory pointer.
-
reallocateUnpooled
public static void reallocateUnpooled(long memPtr, int cap)Reallocate unpooled memory chunk.- Parameters:
memPtr- Memory pointer.cap- Minimum capacity.
-
releaseUnpooled
public static void releaseUnpooled(long memPtr)
Release unpooled memory chunk.- Parameters:
memPtr- Memory pointer.
-
allocatePool
public static long allocatePool()
Allocate pool memory.- Returns:
- Pool pointer.
-
releasePool
public static void releasePool(long poolPtr)
Release pool memory.- Parameters:
poolPtr- Pool pointer.
-
allocatePooled
public static long allocatePooled(long poolPtr, int cap)Allocate pooled memory chunk.- Parameters:
poolPtr- Pool pointer.cap- Capacity.- Returns:
- Cross-platform memory pointer or
0in case there are no free memory chunks in the pool.
-
reallocatePooled
public static void reallocatePooled(long memPtr, int cap)Reallocate pooled memory chunk.- Parameters:
memPtr- Memory pointer.cap- Minimum capacity.
-
releasePooled
public static void releasePooled(long memPtr)
Release pooled memory chunk.- Parameters:
memPtr- Memory pointer.
-
reallocate
public static void reallocate(long memPtr, int cap)Reallocate arbitrary memory chunk.- Parameters:
memPtr- Memory pointer.cap- Capacity.
-
-