JDK-8309304 : Abort the VM if MaxNewSize is not the same as NewSize when MaxHeapSize is the same as InitialHeapSize
  • Type: CSR
  • Component: hotspot
  • Sub-Component: gc
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 22
  • Submitted: 2023-06-01
  • Updated: 2023-11-11
  • Resolved: 2023-06-26
Related Reports
CSR :  
Relates :  
Relates :  
Description
Summary
-------

Exit the VM if users provide different `NewSize` and `MaxNewSize` when `InitialHeapSize` and `MaxHeapSize` are the same. Affects only Serial and Parallel GC.

Problem
-------

`MaxNewSize` can be silently ignored in certain cases. For example:

```
java -XX:+UseSerialGC
  -XX:InitialHeapSize=256m -XX:MaxHeapSize=256M
  -XX:NewSize=8M -XX:MaxNewSize=80M
  '-Xlog:gc,gc+heap=trace' --version
```

sets initial and maximum young generation size to 8 MB, meaning that `MaxNewSize=80M` is silently ignored, which can be surprising. This is especially true when `-XX:InitialHeapSize=256m` (or an even larger value) is derived from the default and implicit `InitialRAMPercentage`.

Solution
--------

Exit the VM with a warning to instruct users to adjust values for `NewSize/MaxNewSize` and/or `InitialHeapSize/MaxHeapsize`.

Specification
-------------

```
    // The maximum and initial heap sizes are the same, so the generation's
    // initial size must be the same as its maximum size.
    if (FLAG_IS_CMDLINE(NewSize) && FLAG_IS_CMDLINE(MaxNewSize) && NewSize != MaxNewSize) {
      vm_exit_during_initialization(
          "The MaxNewSize must be the same as NewSize because the MaxHeapSize and InitialHeapSize are the same.");
    }
```


Comments
The corresponding patch JDK-8047998 is revoked by JDK-8311215. If the redo issue JDK-8311214 is not solved at JDK-22, what should we deal with this CSR? Also revoke this csr or only adjust the fix version?
11-11-2023

Moving to Approved.
26-06-2023