Java in a Container

From NovaOrdis Knowledge Base
Revision as of 19:32, 6 November 2019 by Ovidiu (Talk | contribs) (Experimental Options)

Jump to: navigation, search




When running java in a container, the max heap should always be explicitly set with -Xmx, based on the application needs and the container limits.

Java max heap limit can also be calculated based on the container limits.

Generic script that correlates JVM memory settings to the container limits:,

Let JVM Adjust Memory Relative to CGroups Limits

Experimental Options

Java 1.8.0_181

java -XX:+UnlockExperimentalVMOptions  -XX:+UseCGroupMemoryLimitForHeap -XX:+PrintFlagsFinal -version | | grep MaxHeapSize

Java 1.8.0_221

java -XX:MaxRAMPercentage=20.0 -XX:+PrintFlagsFinal -version | grep MaxHeapSize

Other flags: