8190283: Default heap sizing options select a MaxHeapSize larger than available physical memory in some cases
Reviewed-by: tschatzl, sjohanss
--- a/src/hotspot/share/runtime/arguments.cpp Tue Nov 07 13:51:18 2017 +0100
+++ b/src/hotspot/share/runtime/arguments.cpp Tue Nov 07 10:30:53 2017 -0500
@@ -2089,9 +2089,10 @@
// respecting the maximum and minimum sizes of the heap.
if (FLAG_IS_DEFAULT(MaxHeapSize)) {
julong reasonable_max = (julong)((phys_mem * MaxRAMPercentage) / 100);
- if (phys_mem <= (julong)((MaxHeapSize * MinRAMPercentage) / 100)) {
+ const julong reasonable_min = (julong)((phys_mem * MinRAMPercentage) / 100);
+ if (reasonable_min < MaxHeapSize) {
// Small physical memory, so use a minimum fraction of it for the heap
- reasonable_max = (julong)((phys_mem * MinRAMPercentage) / 100);
+ reasonable_max = reasonable_min;
} else {
// Not-small physical memory, so require a heap at least
// as large as MaxHeapSize