Resources

Traditionally the jvm looks in the /proc file system to find out how many cpus and memory is available. This assumes the whole machine is available and does not work with containers cgroup limits. Additionally one garbage collection thread is started per available cpu core even if the container may use only one cpu.

But in Java 10 -XX:+UseContainerSupport is enabled by default, so the container limits are respected. -XX:MaxRAMPercentage=80 then would use 80% of the containers ram.

For an old version of java the max heap and non-heap areas must be set each: -Xmx288m -XX:CompressedClassSpaceSize=32m -XX:MaxMetaspaceSize=128m -XX:ReservedCodeCacheSize=64m this fits for 512m RAM limit.

Garbage Collection

By default the jvm uses 1% of cpu time for garbage collection. This can be increased with: -XX:GCTimeRatio=9 It means that N/(N+1) is the part of time for application threads.

Also in a Container before Java 10 it is useful to set -XX:+UseSerialGC