GC Setting Parameters

This entry will guide you to specify the minimum and maximum heap size for the JVM respectively depends on the value of Server specs e.g the RAM size. Attached is the GC setting example that was tested in both OpenJDK 1.8 and OpenJDK 11. Note that attached examples was set to minimum and maximum heap size is set to 5GB. Do note that you will need to tune the GC parameters to best suit your environment.

Note : This is useful when you encounter Garbage Collection (GC) allocation failure which occurs when the Java heap (the memory area where Java objects are stored) runs out of space to allocate new objects. This can cause the Java application to stop responding, or even to crash.

OpenJDK 1.8.0_312

run-server script:

#!/bin/sh
DATE=date +'%Y%m%d_%H%M'
#GCLOG=/logs/elx_ambience/hostname.AmbienceServer_GC_${DATE}.log
cd …
OPTIONS=“-Dvisualvm.display.name=AmbienceServer -Delixir.home=. -Djetty.home=jetty -Djetty.base=jetty/elx-base -Djava.awt.headless=true -Dlogback.configurationFile=etc/logback.xml -Djetty.port:8080 -Djetty.context=/elx”
java $OPTIONS -server -XX:+DisableExplicitGC -XX:+UseG1GC -Xms2560m -Xmx5120m -Xloggc:$GCLOG -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=20 -XX:GCLogFileSize=10M -XX:+PrintGCApplicationStoppedTime -XX:+DoEscapeAnalysis -jar elx-stub.jar org.eclipse.jetty.start.Main

Oracle OpenJDK 11.0.15

run-server script:

#!/bin/sh
DATE=date +'%Y%m%d_%H%M'
cd …
OPTIONS=“-Dvisualvm.display.name=AmbienceServer -Delixir.home=. -Djetty.home=jetty -Djetty.base=jetty/elx-base -Djava.awt.headless=true -Dlogback.configurationFile=etc/logback.xml -Djetty.port:8080 -Djetty.context=/elx”
java $OPTIONS -server -XX:+DisableExplicitGC -XX:+UseG1GC -Xms2560m -Xmx5120m -XX:+DoEscapeAnalysis -jar elx-stub.jar org.eclipse.jetty.start.Main

Do refer to the following references to determine which GC settings work best for your environment:

https://docs.oracle.com/cd/E55119_01/doc.71/e55122/cnf_jvmgc.htm#WSEAD414