mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
Ergonomics now also takes available virtual memory into account when deciding for a heap size. The helper method to determine the maximum allocatable memory block now uses the appropriate OS specific calls to retrieve available virtual memory for the java process. In 32 bit environments this method now also searches for the maximum actually reservable amount of memory. Merge previously separate implementations for Linux/BSD/Solaris into a single method. Reviewed-by: jmasa, tamao
This commit is contained in:
parent
89120e7827
commit
bb5bd507d7
9 changed files with 92 additions and 57 deletions
|
@ -1552,6 +1552,15 @@ void Arguments::set_g1_gc_flags() {
|
|||
}
|
||||
}
|
||||
|
||||
julong Arguments::limit_by_allocatable_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
|
||||
|
@ -1590,12 +1599,12 @@ void Arguments::set_heap_size() {
|
|||
}
|
||||
reasonable_max = MIN2(reasonable_max, max_coop_heap);
|
||||
}
|
||||
reasonable_max = os::allocatable_physical_memory(reasonable_max);
|
||||
reasonable_max = limit_by_allocatable_memory(reasonable_max);
|
||||
|
||||
if (!FLAG_IS_DEFAULT(InitialHeapSize)) {
|
||||
// An initial heap size was specified on the command line,
|
||||
// so be sure that the maximum size is consistent. Done
|
||||
// after call to allocatable_physical_memory because that
|
||||
// after call to limit_by_allocatable_memory because that
|
||||
// method might reduce the allocation size.
|
||||
reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize);
|
||||
}
|
||||
|
@ -1615,14 +1624,14 @@ void Arguments::set_heap_size() {
|
|||
|
||||
reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
|
||||
|
||||
reasonable_minimum = os::allocatable_physical_memory(reasonable_minimum);
|
||||
reasonable_minimum = limit_by_allocatable_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 = limit_by_allocatable_memory(reasonable_initial);
|
||||
|
||||
if (PrintGCDetails && Verbose) {
|
||||
// Cannot use gclog_or_tty yet.
|
||||
|
@ -2608,9 +2617,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args,
|
|||
initHeapSize = MIN2(total_memory / (julong)2,
|
||||
total_memory - (julong)160*M);
|
||||
|
||||
// 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 = limit_by_allocatable_memory(initHeapSize);
|
||||
|
||||
if (FLAG_IS_DEFAULT(MaxHeapSize)) {
|
||||
FLAG_SET_CMDLINE(uintx, MaxHeapSize, initHeapSize);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue