## org.h2.util
Class MemoryUtils

    java.lang.Object
      org.h2.util.MemoryUtils

    public class MemoryUtils

extends java.lang.Object

This is a utility class with functions to measure the free and used memory.

Field Summary
`static byte[]` `EMPTY_BYTES` An 0-size byte array.
`static int[]` `EMPTY_INT_ARRAY` An 0-size int array.
`static long[]` `EMPTY_LONG_ARRAY` An 0-size long array.

Method Summary
`static int` `getMemoryFree()` Get the free memory in KB.
`static int` `getMemoryUsed()` Get the used memory in KB.
`static byte[]` `newBytes(int len)` Create an array of bytes with the given size.
`static int[]` `newIntArray(int len)` Create an int array with the given size.
`static long[]` `newLongArray(int len)` Create a long array with the given size.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### EMPTY_BYTES

    public static final byte[] EMPTY_BYTES

  An 0-size byte array.

### EMPTY_INT_ARRAY

    public static final int[] EMPTY_INT_ARRAY

  An 0-size int array.

### EMPTY_LONG_ARRAY

    public static final long[] EMPTY_LONG_ARRAY

  An 0-size long array.

Method Detail

### getMemoryUsed

    public static int getMemoryUsed()

  Get the used memory in KB.

  Returns:
    the used memory

### getMemoryFree

    public static int getMemoryFree()

  Get the free memory in KB.

  Returns:
    the used memory

### newBytes

    public static byte[] newBytes(int len)

  Create an array of bytes with the given size. If this is not possible because not enough memory is available, an OutOfMemoryError with the requested size in the message is thrown.

  Parameters:
    `len` - the number of bytes requested
  Returns:
    the byte array
  Throws:
    `java.lang.OutOfMemoryError`

### newIntArray

    public static int[] newIntArray(int len)

  Create an int array with the given size.

  Parameters:
    `len` - the number of bytes requested
  Returns:
    the int array

### newLongArray

    public static long[] newLongArray(int len)

  Create a long array with the given size.

  Parameters:
    `len` - the number of bytes requested
  Returns:
    the int array