JDK-8222487 : Release Note: Added -XX:SoftMaxHeapSize Flag
  • Type: Sub-task
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 13
  • Priority: P4
  • Status: Closed
  • Resolution: Delivered
  • Submitted: 2019-04-15
  • Updated: 2019-08-08
  • Resolved: 2019-06-07
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 13
13Resolved
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.