Search code examples
javaopenjdk-11

OpenJDK MaxRAMPercentage on a machine with very large amount of memory


When running OpenJDK 11 on a machine with 60GB of memory (and more), the MaxRAMPercentage only allows me to allocate up to around 30GB.

This works correctly:

>~# java   -XX:MaxRAMPercentage=10 -XshowSettings:vm -version
VM settings:
    Max. Heap Size (Estimated): 5.90G
    Using VM: OpenJDK 64-Bit Server VM

openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Debian-1bpo91)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Debian-1bpo91, mixed mode, sharing)

But when the percentage should produce a heap size above 30G, I get:

>~# java   -XX:MaxRAMPercentage=75 -XshowSettings:vm -version
VM settings:
    Max. Heap Size (Estimated): 29.97G
    Using VM: OpenJDK 64-Bit Server VM

openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Debian-1bpo91)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Debian-1bpo91, mixed mode, sharing)

Using good old -Xmx works (e.g. -Xmx50G).

What am I missing? Is MaxRAMPercentage supposed to be bounded?


Solution

  • The problem is a bug/feature related to CompressedOops (CompressedOops limits the heap size to 32GB, and while -Xmx disables CompressedOops, MaxRAMPercentage doesn't).

    To solve / workaround you can either:

    • Add -XX:-UseCompressedOops to disable CompressedOops
    • Use OpenJDK13, where the bug is fixed

    The bug report is here. HT @Arnaud for directing me there.