8190283: Default heap sizing options select a MaxHeapSize larger than available physical memory in some cases
authorbobv
Tue, 07 Nov 2017 10:30:53 -0500
changeset 47801 c7b50c23ea71
parent 47800 df4f4688b13d
child 47802 18dccdc438d7
8190283: Default heap sizing options select a MaxHeapSize larger than available physical memory in some cases Reviewed-by: tschatzl, sjohanss
src/hotspot/share/runtime/arguments.cpp
--- 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