Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8222145 Add -XX:SoftMaxHeapSize flag
  3. JDK-8222487

Release Note: Added -XX:SoftMaxHeapSize Flag

    XMLWordPrintable

Details

    • gc
    • Verified

    Description

      The manageable command-line flag `-XX:SoftMaxHeapSize=<bytes>` has been added. Currently, it only has an effect when the Z garbage collector is enabled (`-XX:+UseZGC`).

      When set, the GC will strive to not grow the heap beyond the specified size, unless the GC decides it's necessary to do so to avoid OutOfMemoryError. The soft max heap size is not allowed to be set to a value greater than the maximum heap size (`-Xmx`). When not set on the command line, it defaults to a value equal to the maximum heap size.

      Being `manageable`, its value can be adjusted at runtime. For example, its value can be adjusted by using `jcmd VM.set_flag SoftMaxHeapSize <bytes>` or through the HotSpot MXBean.

      Setting this flag can be useful in a number of situations, such as:

      * In environments where resource usage is a concern, you might want to keep the heap footprint down while also retaining the capability to deal with a temporary increase in heap space requirement.

      * When using a concurrent GC (such as ZGC), you might want to play it safe and increase the confidence level that you will not run into an allocation stall because of an unforeseen increase in allocation rate. Setting a soft max heap size encourages the GC to maintain a smaller heap, which means the GC will collect garbage more aggressively than it otherwise would, making it more resilient to a sudden increase in the application allocation rate.

      Attachments

        Activity

          People

            pliden Per Liden (Inactive)
            pliden Per Liden (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: