Skip to content

Commit 6380ebb

Browse files
committed
Pass -XX:+UseCompressedOops to get a warning if the max heap size is too large for compressed oops
1 parent 7782ba3 commit 6380ebb

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ public record HostFlags(
351351
boolean hasGCTimeRatio,
352352
boolean hasExitOnOutOfMemoryError,
353353
boolean hasMaximumHeapSizePercent,
354-
boolean hasUseParallelGC) {
354+
boolean hasUseParallelGC,
355+
boolean hasUseCompressedOops) {
355356

356357
public List<String> defaultMemoryFlags() {
357358
List<String> flags = new ArrayList<>();
@@ -372,6 +373,12 @@ public List<String> defaultMemoryFlags() {
372373
*/
373374
flags.add("-XX:+ExitOnOutOfMemoryError");
374375
}
376+
if (hasUseCompressedOops) {
377+
/*
378+
* To print a warning if the max heap size is too large for compressed oops.
379+
*/
380+
flags.add("-XX:+UseCompressedOops");
381+
}
375382
return flags;
376383
}
377384
}
@@ -574,6 +581,7 @@ private HostFlags gatherHostFlags() {
574581
boolean hasGCTimeRatio = false;
575582
boolean hasExitOnOutOfMemoryError = false;
576583
boolean hasUseParallelGC = false;
584+
boolean hasUseCompressedOops = false;
577585

578586
ProcessBuilder pb = new ProcessBuilder();
579587
sanitizeJVMEnvironment(pb.environment(), Map.of());
@@ -604,6 +612,8 @@ private HostFlags gatherHostFlags() {
604612
hasMaximumHeapSizePercent = true;
605613
} else if (line.contains(" UseParallelGC ")) {
606614
hasUseParallelGC = true;
615+
} else if (line.contains(" UseCompressedOops ")) {
616+
hasUseCompressedOops = true;
607617
}
608618
}
609619
}
@@ -623,7 +633,8 @@ private HostFlags gatherHostFlags() {
623633
hasGCTimeRatio,
624634
hasExitOnOutOfMemoryError,
625635
hasMaximumHeapSizePercent,
626-
hasUseParallelGC);
636+
hasUseParallelGC,
637+
hasUseCompressedOops);
627638
}
628639

629640
/**

0 commit comments

Comments
 (0)