How to change the Garbage collection options on JBoss EAP on OpenShift

Solution Verified - Updated -

Environment

  • JBoss Enterprise Application Platform (EAP) 6.x, 7,x
    • on OpenShift

Issue

We need to find a way to change the default Garbage Collector settings in the JVM used by JBoss EAP on OpenShift

Resolution

  • For EAP 64 version 1.6 and later , follow this solution article.
  • For EAP 64 till version 1.5 follow below steps:
    Use the JAVA_OPTS_APPEND environment variable to add new options to the JVM. See the following example, how to set the JVM non standard option -XX:+UseG1GC in the Deployment Config of a running EAP image:
$ oc get dc
NAME      REVISION   DESIRED   CURRENT   TRIGGERED BY
demoeap   3          1         1         config,image(demoeap:latest)

$ oc env dc/demoeap JAVA_OPTS_APPEND=-XX:+UseG1GC

Now you can check from the Pod logs that the option -XX:+UseG1GC has been included in the JBoss EAP JVM:

$ oc logs demoeap-3-7k00d  

Running jboss-eap-7/eap70-openshift image, version 1.4-30
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/eap

  JAVA: /usr/lib/jvm/java-1.8.0/bin/java

  JAVA_OPTS:  -server -verbose:gc -Xloggc:"/opt/eap/standalone/log/gc.log" -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCL
ogFileSize=3M -XX:-TraceClassUnloading -Xms1303m -Xmx1303m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss
.logmanager,jdk.nashorn.api -Djava.awt.headless=true -Xbootclasspath/p:/opt/eap/jboss-modules.jar:/opt/eap/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager
-2.0.3.Final-redhat-1.jar:/opt/eap/modules/system/layers/base/org/jboss/logmanager/ext/main/jboss-logmanager-ext-1.0.0.Alpha2-redhat-1.jar -Djava.util.logging.manager=org.jboss
.logmanager.LogManager -javaagent:/opt/eap/jolokia.jar=port=8778,protocol=https,caCert=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt,clientPrincipal=cn=system:master-pro
xy,useSslClientAuthentication=true,extraClientCheck=true,host=0.0.0.0,discoveryEnabled=false -Djava.security.egd=file:/dev/./urandom -XX:+UseG1GC

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.