8190283: Default heap sizing options select a MaxHeapSize larger than available physical memory in some cases

Reviewed-by: tschatzl, sjohanss
This commit is contained in:
Bob Vandette 2017-11-07 10:30:53 -05:00
parent d7b2fafd3d
commit 75d5090c81

View File

@ -2089,9 +2089,10 @@ void Arguments::set_heap_size() {
// 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