Java Configuration

Out of Memory

There are a few parameters for the JVM that might need to be adjusted a little for a given server installation. Depending on the amount of available primary memory and the amount of disk swap space, it might be necessary to inform the JVM how much memory it is allowed to allocate. The Unix process, running an EC, can fork itself depending on configurations in individual agents. The Disk forwarding agent, for instance, can be configured to run an external binary after every forwarded file. The JVM performs a native fork-call to do this, and the forked JVM process will initially have the same memory footprint as the parent process. If there is not enough primary memory and/or swap space available, the EC will abort with the following exception:

java.io.IOException: Not enough space at java.lang.UNIXProcess.forkAndExec(Native Method) 

If this happens, the maximum heap size for the JVM must be lowered, or additional memory must be added to the machine. Lowering the memory can be done by using the JVM argument  -Xmx , which is specified for all pico configurations.

The following line is an example of how to specify this JVM argument in the STR.

mzsh topo set topo://container:<container>/pico:<pico>/obj:config.jvmargs \ 'xmx:["-Xmx128M"]'

Unfortunately, it is difficult to recommend a value. This JVM argument  specifies the maximum heap size, meaning that the JVM will probably not reach this limit for a while, depending on how the JVM manages its heap. That, in turn, means that the forking will work for a while, and when the heap size in the JVM has grown large enough, the fork will fail in case there is no free memory pages available in the machine.

The only possible recommendation is to lower the maximum heap size value, or to add more system resources (memory or swap disk). If the physical host is running more than one Execution Context, then the memory allocation of these Execution Contexts must be taken into account as well.

The JVM also has a kind of memory called direct memory, which is distinct from normal JVM heap memory. You may need to increase the direct buffer memory when Shared Tables have been configured to use off-heap memory. This can be done by either by increasing the maximum heap size, which increases both the maximum heap and the maximum direct memory, or by only increasing the maximum direct memory using the JVM argument XX:MaxDirectMemorySize.

The more memory a JVM is given, the better it will perform. However, make sure that the heap never "pages". The sum of all maximum heaps must fit in physical memory. Make sure to adapt these values to better fit the memory in the installed machine. Increasing the heap size for an EC can make a big difference to performance.