4

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?

daphshez
  • 9,272
  • 11
  • 47
  • 65
  • 1
    This bug may be related : https://bugs.openjdk.java.net/browse/JDK-8213175 – Arnaud Sep 26 '19 at 14:48
  • Perhaps this [answer](https://stackoverflow.com/a/54297753/3301492) might be helpful. – Boris Sep 26 '19 at 14:57
  • @Arnaud, thanks, that was indeed the problem. Would you like to put this as an answer so I can vote it up? – daphshez Sep 26 '19 at 16:18
  • Well @daphshez, that was just a hint and I don't know how it is fixed/workarounded. If it is clearer for you, don't hesitate to answer your own question :) – Arnaud Sep 26 '19 at 16:26

1 Answers1

13

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.

daphshez
  • 9,272
  • 11
  • 47
  • 65