org.apache.ignite.internal.processors.platform.memory

## 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
`static long` `BOOLEAN_ARR_OFF` Array offset: boolean.
`static long` `BYTE_ARR_OFF` Array offset: byte.
`static long` `CHAR_ARR_OFF` Array offset: char.
`static long` `DOUBLE_ARR_OFF` Array offset: double.
`static int` `FLAG_ACQUIRED` Flag: whether this pooled memory chunk is acquired.
`static int` `FLAG_EXT` Flag: external.
`static int` `FLAG_POOLED` Flag: pooled.
`static long` `FLOAT_ARR_OFF` Array offset: float.
`static long` `INT_ARR_OFF` Array offset: int.
`static boolean` `LITTLE_ENDIAN` Whether little endian is used on the platform.
`static long` `LONG_ARR_OFF` Array offset: long.
`static int` `MEM_HDR_LEN` Memory chunk header length.
`static int` `MEM_HDR_OFF_CAP` Offset: capacity.
`static int` `MEM_HDR_OFF_FLAGS` Offset: flags.
`static int` `MEM_HDR_OFF_LEN` Offset: length.
`static int` `POOL_HDR_LEN` Header length.
`static int` `POOL_HDR_OFF_MEM_1` Pool header offset: first memory chunk.
`static int` `POOL_HDR_OFF_MEM_2` Pool header offset: second memory chunk.
`static int` `POOL_HDR_OFF_MEM_3` Pool header offset: third memory chunk.
`static long` `SHORT_ARR_OFF` Array offset: short.
`static sun.misc.Unsafe` `UNSAFE` Unsafe instance.

### Method Summary

Methods
`static long` `allocatePool()` Allocate pool memory.
`static long` `allocatePooled(long poolPtr, int cap)` Allocate pooled memory chunk.
`static long` `allocateUnpooled(int cap)` Allocate unpooled memory chunk.
`static int` `capacity(long memPtr)` Gets capacity for the given memory chunk.
`static void` `capacity(long memPtr, int cap)` Sets capacity for the given memory chunk.
`static long` `data(long memPtr)` Gets data pointer for the given memory chunk.
`static int` `flags(long memPtr)` Gets flags for the given memory chunk.
`static void` `flags(long memPtr, int flags)` Sets flags for the given memory chunk.
`static boolean` `isAcquired(int flags)` Check whether flags denote pooled and acquired memory chunk.
`static boolean` `isAcquired(long memPtr)` Check whether this memory chunk is pooled and acquired.
`static boolean` `isExternal(int flags)` Check whether flags denote that this memory chunk is external.
`static boolean` `isExternal(long memPtr)` Check whether this memory chunk is external.
`static boolean` `isPooled(int flags)` Check whether flags denote pooled memory chunk.
`static boolean` `isPooled(long memPtr)` Check whether this memory chunk is pooled.
`static int` `length(long memPtr)` Gets length for the given memory chunk.
`static void` `length(long memPtr, int len)` Sets length for the given memory chunk.
`static void` `reallocate(long memPtr, int cap)` Reallocate arbitrary memory chunk.
`static void` `reallocatePooled(long memPtr, int cap)` Reallocate pooled memory chunk.
`static void` `reallocateUnpooled(long memPtr, int cap)` Reallocate unpooled memory chunk.
`static void` `releasePool(long poolPtr)` Release pool memory.
`static void` `releasePooled(long memPtr)` Release pooled memory chunk.
`static void` `releaseUnpooled(long memPtr)` Release unpooled memory chunk.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### UNSAFE

    public static final sun.misc.Unsafe UNSAFE

Unsafe instance.

#### BOOLEAN_ARR_OFF

    public static final long BOOLEAN_ARR_OFF

Array offset: boolean.

#### BYTE_ARR_OFF

    public static final long BYTE_ARR_OFF

Array offset: byte.

#### SHORT_ARR_OFF

    public static final long SHORT_ARR_OFF

Array offset: short.

#### CHAR_ARR_OFF

    public static final long CHAR_ARR_OFF

Array offset: char.

#### INT_ARR_OFF

    public static final long INT_ARR_OFF

Array offset: int.

#### FLOAT_ARR_OFF

    public static final long FLOAT_ARR_OFF

Array offset: float.

#### LONG_ARR_OFF

    public static final long LONG_ARR_OFF

Array offset: long.

#### DOUBLE_ARR_OFF

    public static final long DOUBLE_ARR_OFF

Array offset: double.

#### LITTLE_ENDIAN

    public static final boolean LITTLE_ENDIAN

Whether little endian is used on the platform.

#### 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:
  `True` if 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:
  `True` if owned by native platform.

#### isPooled

    public static boolean isPooled(long memPtr)

Check whether this memory chunk is pooled.

Parameters:
  `memPtr` - Memory pointer.
Returns:
  `True` if pooled.

#### isPooled

    public static boolean isPooled(int flags)

Check whether flags denote pooled memory chunk.

Parameters:
  `flags` - Flags.
Returns:
  `True` if pooled.

#### isAcquired

    public static boolean isAcquired(long memPtr)

Check whether this memory chunk is pooled and acquired.

Parameters:
  `memPtr` - Memory pointer.
Returns:
  `True` if pooled and acquired.

#### isAcquired

    public static boolean isAcquired(int flags)

Check whether flags denote pooled and acquired memory chunk.

Parameters:
  `flags` - Flags.
Returns:
  `True` if 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 `0` in 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.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.5.0.final
Release Date | : December 29 2015