--- old/src/share/vm/runtime/arguments.cpp 2013-03-13 09:05:09.140389429 +0100 +++ new/src/share/vm/runtime/arguments.cpp 2013-03-13 09:05:08.988389436 +0100 @@ -1546,6 +1546,15 @@ } } +julong Arguments::allocatable_physical_memory(julong limit) { + julong max_allocatable; + julong result = limit; + if (os::has_allocatable_memory_limit(max_allocatable)) { + result = MIN2(result, max_allocatable / MaxVirtMemFraction); + } + return result; +} + void Arguments::set_heap_size() { if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) { // Deprecated flag @@ -1561,7 +1570,7 @@ // respecting the maximum and minimum sizes of the heap. if (FLAG_IS_DEFAULT(MaxHeapSize)) { julong reasonable_max = phys_mem / MaxRAMFraction; - + if (phys_mem <= MaxHeapSize * MinRAMFraction) { // Small physical memory, so use a minimum fraction of it for the heap reasonable_max = phys_mem / MinRAMFraction; @@ -1584,7 +1593,7 @@ } reasonable_max = MIN2(reasonable_max, max_coop_heap); } - reasonable_max = os::allocatable_physical_memory(reasonable_max); + reasonable_max = allocatable_physical_memory(reasonable_max); if (!FLAG_IS_DEFAULT(InitialHeapSize)) { // An initial heap size was specified on the command line, @@ -1609,14 +1618,14 @@ reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize); - reasonable_minimum = os::allocatable_physical_memory(reasonable_minimum); + reasonable_minimum = allocatable_physical_memory(reasonable_minimum); julong reasonable_initial = phys_mem / InitialRAMFraction; reasonable_initial = MAX2(reasonable_initial, reasonable_minimum); reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize); - reasonable_initial = os::allocatable_physical_memory(reasonable_initial); + reasonable_initial = allocatable_physical_memory(reasonable_initial); if (PrintGCDetails && Verbose) { // Cannot use gclog_or_tty yet. @@ -2597,7 +2606,7 @@ // Make sure that if we have a lot of memory we cap the 32 bit // process space. The 64bit VM version of this function is a nop. - initHeapSize = os::allocatable_physical_memory(initHeapSize); + initHeapSize = allocatable_physical_memory(initHeapSize); if (FLAG_IS_DEFAULT(MaxHeapSize)) { FLAG_SET_CMDLINE(uintx, MaxHeapSize, initHeapSize);