Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8321292

SerialGC: NewSize vs InitialHeapSize check has an off-by-one error

XMLWordPrintable

    • gc
    • b25

      The following code complains if NewSize is set the same as InitialHeapSize (or -Xms):
        // Make sure NewSize allows an old generation to fit even if set on the command line
        if (FLAG_IS_CMDLINE(NewSize) && NewSize >= InitialHeapSize) {
          log_warning(gc, ergo)("NewSize was set larger than initial heap size, will use initial heap size.");
          FLAG_SET_ERGO(NewSize, bound_minus_alignment(NewSize, InitialHeapSize, GenAlignment));
        }

      This is the output of a few runs:

      $ ../build/fastdebug/jdk/bin/java -Xlog:gc+init,heap*=trace,exit*=off -XX:+UseSerialGC -Xmx256m -Xms128m -XX:NewSize=128m -version
      ```
      [0.012s][info][gc,init] CardTable entry size: 512
      [0.012s][warning][gc,ergo] NewSize was set larger than initial heap size, will use initial heap size.
      [0.012s][debug ][gc,heap] Minimum heap 134217728 Initial heap 134217728 Maximum heap 268435456
      [0.012s][trace ][gc,heap] 1: Minimum young 134152192 Initial young 134152192 Maximum young 134152192
      [0.012s][trace ][gc,heap] Minimum old 65536 Initial old 65536 Maximum old 134283264
      ```
      $ ../build/fastdebug/jdk/bin/java -Xlog:gc+init,heap*=trace,exit*=off -XX:+UseSerialGC -Xmx256m -Xms128m -XX:NewSize=134217728 -version
      ```
      [0.012s][info][gc,init] CardTable entry size: 512
      [0.012s][warning][gc,ergo] NewSize was set larger than initial heap size, will use initial heap size.
      [0.012s][debug ][gc,heap] Minimum heap 134217728 Initial heap 134217728 Maximum heap 268435456
      [0.012s][trace ][gc,heap] 1: Minimum young 134152192 Initial young 134152192 Maximum young 134152192
      [0.012s][trace ][gc,heap] Minimum old 65536 Initial old 65536 Maximum old 134283264
      ```
      $ ../build/fastdebug/jdk/bin/java -Xlog:gc+init,heap*=trace,exit*=off -XX:+UseSerialGC -Xmx256m -Xms128m -XX:NewSize=134217727 -version
      ```
      [0.019s][info][gc,init] CardTable entry size: 512
      [0.019s][debug][gc,heap] Minimum heap 134217728 Initial heap 134217728 Maximum heap 268435456
      [0.019s][trace][gc,heap] 1: Minimum young 134152192 Initial young 134152192 Maximum young 134152192
      [0.019s][trace][gc,heap] Minimum old 65536 Initial old 65536 Maximum old 134283264
      ```

      It is unclear if there's an actual problem with the code, or if this is just a very misleading warning message.

            tschatzl Thomas Schatzl
            stefank Stefan Karlsson
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: