Java app crash OutOfMemory: Metaspace on OpenShift
Issue
- Using image
openjdk18-openshift:1.2-7, trying to override JVM options for-XX:MaxMetaspaceSize=<size>m. When setting this parameter inJAVA_OPTSusing-XX:MaxMetaspaceSize=300m, Openshift overrides this value with-XX:MaxMetaspaceSize=100m.
JVM startup log with final flags for metaspace below...
Starting the Java application using /opt/run-java/run-java.sh ...
exec java -Dspring.profiles.active=dev -Dserver.port=8080 -Djavax.net.ssl.trustStorePassword=changeit -Djavax.net.ssl.trustStore=/etc/alternatives/java_sdk/lib/security/cacerts -Xms1000M -Xmx1000M -XX:+PrintFlagsFinal -Dappdynamics.agent.reuse.nodeName=true -Dappdynamics.agent.reuse.nodeName.prefix=example -Dappdynamics.jvm.shutdown.mark.node.as.historical=true -javaagent:/opt/appdynamics/javaagent.jar -XX:+UseParallelGC -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MaxMetaspaceSize=300m -XX:+UseParallelGC -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MaxMetaspaceSize=100m -XX:ParallelGCThreads=4 -Djava.util.concurrent.ForkJoinPool.common.parallelism=4 -XX:CICompilerCount=2 -XX:+ExitOnOutOfMemoryError -cp . -jar /deployments/example.jar
[Global flags]
...
...
uintx MaxMetaspaceExpansion = 5451776 {product}
uintx MaxMetaspaceFreeRatio = 70 {product}
uintx MaxMetaspaceSize := 104857600 {product}
Environment
- OpenShift Container Platform 3.6
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
