JDK-8047998 : -XX:InitialHeapSize is unnecessarily set to MaxHeapSize
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 9
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2014-06-24
  • Updated: 2022-11-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21
21Unresolved
Description
The problem arises in Arguments::set_heap_size when ergonomically calculating the value for InitialHeapSize. A user might have specified a certain value for -XX:MaxHeapSize, for example 512m. If the machine has a lot of RAM, and InitialRAMFraction is unchanged, then:

  julong reasonable_initial = phys_mem / InitialRAMFraction;

might become larger than MaxHeapSize. This will cause:

  reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);

to equal MaxHeapSize. This is not a huge problem until GenCollectorPolicy::initialize_size_info:

  if (_max_heap_byte_size == _initial_heap_byte_size) {
    // The maximum and initial heap sizes are the same so the generation's
    // initial size must be the same as it maximum size. Use NewSize as the
    // size if set on command line.
    _max_young_size = FLAG_IS_CMDLINE(NewSize) ? NewSize : _max_young_size;
    _initial_young_size = _max_young_size;

    // Also update the minimum size if min == initial == max.
    if (_max_heap_byte_size == _min_heap_byte_size) {
      _min_young_size = _max_young_size;
    }
  }

This might cause an unexpected value for MaxNewSize.
Comments
One possible fix is to calculate the value for InitialHeapSize based on MaxHeapSize instead of basing the calculation the amount of physical RAM.
24-06-2014