[Native Image] Improperly specified VM option MaxRAMPercentage
After upgrading from GraalVM 24 to 25, I'm seeing a failure for a native-image build. It is reporting an error like
Improperly specified VM option 'MaxRAMPercentage=248.3526865641276'
I am not setting MaxRAMPercentage anywhere. I think the value is a computed default.
The build is running in an environment where the machine has more physical ram than is available to the process, due to cgroup limits. I wondered if that could be affecting the logic that is sizing MaxRAMPercentage, but it's just a guess.
I don't have a good self-contained repro yet, I can work on creating one.
Were there any changes to how the default for MaxRAMPercentage is computed between 24 and 25 that could be a culprit here?
The native-image command line includes:
-H:+ReportExceptionStackTraces
-H:+StaticExecutableWithDynamicLibC
-H:Log=registerResource:3
-H:-CheckToolchain
--no-fallback
--report-unsupported-elements-at-runtime
-march=x86-64-v2
-R:MinHeapSize=3072m
-R:MaxHeapSize=3072m
--parallelism=4
-H:+UnlockExperimentalVMOptions
-H:-DeleteLocalSymbols
-H:+PreserveFramePointer
-H:-IncludeMethodData
Hi, thank you for reaching out, could you please share a reproducer to this issue, thanks
I spent some time trying to create a reproducer and so far haven't been able to reproduce outside the build machine where I first saw it, it's still reproducing consistently there.
It reproduces when I pass no flags to native-image except for the jar to process, i.e. native-image -jar foo.jar.
I think that machine is using cgroups-v1 to set memory limits.
If I adjust the memory limits for the container I get different errors:
| Improperly specified MaxRAMPercentage option | memory limit in GB |
|---|---|
| 186.2645149 | 16 |
| 149.0116119 | 20 |
| 124.1763433 | 24 |
| 106.43686567034041 | 28 |
Do you know how the defaults for MaxRAMPercentage are supposed to be computed here?
Do you know how the defaults for MaxRAMPercentage are supposed to be computed here?
Perhaps here?
https://github.com/oracle/graal/blob/8ad5cf768bd8f6e661e2e51b197ddc95b9fbfe31/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/MemoryUtil.java#L81C20-L81C45
Looking at that logic, I see handling for the environment variable CI. If I set CI=true, it works around the issue I was seeing with MaxRAMPercentage > 100 in containers.
It seems we should make sure that the heuristic never computes a value above 100.0. Would you like to contribute a fix for this?
Sorry I'm not sure I'll have time to contribute a fix for this.