CAUTION: This site hosts draft documentation for the next release. For published content of the latest release, visit www.eclipse.org/openj9/docs

-XX:[+|-]UseContainerSupport

(Linux® only)

If your application is running in a container that imposes a memory limit, the VM allocates a larger fraction of memory to the Java heap. To turn off this behavior, set the -XX:-UseContainerSupport option on the command line.

Syntax

    -XX:[+|-]UseContainerSupport
Setting Effect Default
-XX:-UseContainerSupport Disable
-XX:+UseContainerSupport Enable yes

When using container technology, applications are typically run on their own and do not need to compete for memory. The OpenJ9 VM detects when it is running inside a container that imposes a memory limit, and adjusts the maximum Java heap size appropriately.

The following table shows the values that are used when -XX:+UseContainerSupport is set:

Container memory limit <size> Maximum Java heap size
Less than 1 GB 50% <size>
1 GB - 2 GB <size> - 512 MB
Greater than 2 GB 75% <size>

The default heap size for containers takes affect only when the following conditions are met:

  1. The application is running in a container environment.
  2. The memory limit for the container is set.
  3. The -XX:+UseContainerSupport option is set, which is the default behavior.

To prevent the VM adjusting the maximum heap size when running in a container, set -XX:-UseContainerSupport.

When -XX:MaxRAMPercentage / -XX:InitialRAMPercentage are used with -XX:+UseContainerSupport, the corresponding heap setting is determined based on the memory limit of the container. For example, to set the maximum heap size to 80% of the container memory, specify the following options:

-XX:+UseContainerSupport -XX:MaxRAMPercentage=80