Skip to content

-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 Eclipse 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 is capped at 25 GB, which is the limit of heap size for 3-bit shift of compressed references (see -Xcompressedrefs), to prevent silent switching to 4-bit shift of compressed references, which has possible performance penalties. You can use the -Xmx option or the -XX:MaxRAMPercentage option to overwrite the 25 GB limit.

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

Note: If you set a value for -Xms, the -XX:InitialRAMPercentage option is ignored. If you set a value for -Xmx, the -XX:MaxRAMPercentage option is ignored.