Skip to content

Commit d985f57

Browse files
committed
Cap Native Image at 31GiB and not 32GB (32 * 10^9)
* Consistent with always reporting memory in GiB.
1 parent 9958b8e commit d985f57

File tree

1 file changed

+7
-4
lines changed
  • substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver

1 file changed

+7
-4
lines changed

substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/MemoryUtil.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,13 @@ public final class MemoryUtil {
6363
private static final int MIN_AVAILABLE_MEMORY_THRESHOLD_GB = 8;
6464

6565
/*
66-
* Builder uses at most 32GB to avoid disabling compressed oops (UseCompressedOops).
67-
* Deliberately use GB (not GiB) to stay well below 32GiB when relative maximum is calculated.
66+
* Builder uses at most 31GiB to avoid disabling compressed oops (UseCompressedOops).
67+
* UseCompressedOops seems currently disabled on my machine at values > (32 GiB - 32 MiB), so we
68+
* use 31 GiB to have some margin. The actual logic at
69+
* https://github.com/openjdk/jdk/blob/jdk-26+10/src/hotspot/share/runtime/arguments.cpp#L1429
70+
* depends on various factors so it seems unwise to hardcode that exact limit.
6871
*/
69-
public static final long MAX_HEAP_BYTES = 32_000_000_000L;
72+
public static final long MAX_HEAP_BYTES = 31 * GiB_TO_BYTES;
7073

7174
public static List<String> heuristicMemoryFlags(HostFlags hostFlags, List<String> memoryFlags) {
7275
/*
@@ -146,7 +149,7 @@ public static Pair<Long, String> maxMemoryHeuristic(long totalMemorySize, boolea
146149
// Ensure max memory size does not exceed upper limit
147150
if (maxMemory > MAX_HEAP_BYTES) {
148151
maxMemory = MAX_HEAP_BYTES;
149-
reason = percentageOfSystemMemoryText(maxMemory, totalMemorySize) + ", capped at 32GB";
152+
reason = percentageOfSystemMemoryText(maxMemory, totalMemorySize) + ", capped at 31GiB";
150153
}
151154

152155
// Handle memory flags

0 commit comments

Comments
 (0)