This article explains how you can find your current JAVA memory configuration and what are the recommended settings.
Find your current settings
The quickest way to check your current configuration is using the option “System Information” in the xDM Application Builder:
A pop-up will display the configuration from your application server, search for the section Runtime Information:
|Note: By default, Tomcat starts up with memory allocation of just 512 megabytes, in many situations, this is not enough. Other JVM configuration options may be important as well.
|Warning: Setting optimal memory options for a Java Virtual Machine is complex. It will be different depending on your exact usage patterns, there is no single answer which can be ideal for all environments.
1. Determine how to set CATALINA_OPTS or JAVA_OPTS in your environment.
- In VMs and AMIs provided by Semarchy on Azure and AWS Marketplace, this is done in the file
- In “Semarchy xDM - Preconfigured with Apache Tomcat” JAVA_OPTS are set in the file
setenv.bat. The default value in xDM 5.2:
CATALINA_OPTS="$CATALINA_OPTS -Xmx512m -server -XX:+UseG1GC -Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Slf4jLogger -Duser.language=en -Duser.country=US -Djava.awt.headless=true"
- In many Linux environments these options set in the file
2. Experiment with different values to see what works best in your environment.
- In many circumstances, the maximum Java heap is the most important setting. Try 4GB as a reasonable first guess for many environments:
Adjust this value up or down depending on your results. It is vital that your operating system actually has this much memory available. If you allocate 4GB to Java but the system only has 3GB available to be allocated, then Tomcat will crash. Oracle recommends a maximum of 1/4 of physical memory.
- Semarchy recommends the Garbage-First (G1) collector for xDM. It meets garbage collection (GC) pause time goals with a high probability while achieving high throughput.
- Semarchy recommends running the JVM in server mode. In very rough terms, the application server starts slower but should run faster.
It is recommended to explicitly set it with the argument