How do I give a process more memory?

There are times when processes run out of memory. In this guide, we cover two common scenarios and how to resolve them.

You may run out of direct memory:

at java.base/java.nio.Bits.reserveMemory(Bits.java:178)
at java.base/java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:121)
at java.base/java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:332)

or Java heap memory:

java.lang.OutOfMemoryError: Java heap space
  • If you run out of direct memory, you need to set -XX:MaxDirectMemorySize=<JVM size argument> to a bigger size. This is most commonly a problem for tailers and for binary logs. The default value we set for tailers is 1500m.
  • If you run out of heap memory, you need to set -Xmx to a bigger size.

For workers, you can change the heap size in the Code Studio startup panel or Persistent Query settings. You may also need to change other parameters by editing the "Extra JVM Arguments" field.

For processes run under monit, this must be done from the hostconfig file by setting EXTRA_ARGS. Preface the actual args you want to pass to Java with -j as shown below:

For example, to raise the size to 2500 MB, update the tailer section of /etc/sysconfig/illumon to read:

    tailer)
        EXTRA_ARGS="$EXTRA_ARGS -j -XX:MaxDirectMemorySize=2500m"
        ;;

If the process ran out of Java heap, your change would look something like this:

    tailer)
        EXTRA_ARGS="$EXTRA_ARGS -j -Xmx8g"
        ;;

The original (non-overridden) values can be found in /etc/sysconfig/illumon.confs/hostconfig.system. However, the tailer's default memory settings are located in /usr/illumon/latest/bin/start_tailer. You can refer to these values to determine the appropriate override values.