I’m messing around with JAVA_MAX_MEM_RATIO to see about saving on memory. With every setting I also adjust the container memory so that I get the following JVM parameters.
exec java -javaagent:/opt/jolokia/jolokia.jar=config=/opt/jolokia/etc/jolokia.properties -Xms512m -Xmx512m -XX:+UseParallelGC -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:MaxMetaspaceSize=256m -XX:ParallelGCThreads=2 -Djava.util.concurrent.ForkJoinPool.common.parallelism=2 -XX:CICompilerCount=2 -XX:+ExitOnOutOfMemoryError -cp . -jar /deployments/opinions-web-swarm.jar
The “Xms512m -Xmx512m” are, to me, the important ones. So, if I set the container memory to 1Gb and the JAVA_MAX_MEM_RATIO to 50% (the default), then I get the above JVM settings and my application works fine.
If I set the container memory to 854Mb and the JAVA_MAX_MEM_RATIO to 60%, then I get the above settings and my application, so far, works fine.
If I set the container memory to 732Mb and the JAVA_MAX_MEM_RATIO to 70%, then I get the above JVM settings and my application CRASHES.
So, something outside the JVM needs more 732-512 or 220Mb (and less than 342, I’m guessing 256?) of memory to run the JVM? Does the OS inside need that much? The image is a wildfly-11-swarm image with EJB/JSF/REST and a few things built inside of openjdk18-openshift:latest image.
Is there some way to configure or know how much the openjdk18-openshift redhat supplied image needs for memory outside of the JVM settings? Should I look into rebuilding it myself if I need to control the memory usage?