JDK-8293863 : Release Note: G1: Disable preventive GCs by default
  • Type: Sub-task
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 20
  • Priority: P4
  • Status: Resolved
  • Resolution: Delivered
  • Submitted: 2022-09-15
  • Updated: 2022-09-23
  • Resolved: 2022-09-19
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 20
20Resolved
Description
In JDK 17 G1 added "preventive" garbage collections (GCs): these are speculative garbage collections, with the goal of avoiding costly evacuation failures due to allocation bursts when the heap is almost full.

However, these (speculative) collections have the consequence of additional garbage collection work - as object aging is based on number of GCs with additional GCs cause premature promotion into the old generation - which leads to more data in the old generation, and more garbage collection work to remove these objects.  This has been compounded by the current prediction to trigger preventive garbage collections being very conservative; which means these garbage collections are often triggered unnecessarily.

In the majority of cases this feature is a net loss, and as evacuation failures are now handled more quickly, there is no longer any reason for this feature and it has been disabled by default, it may be re-enabled by `-XX:+UnlockDiagnosticVMOptions -XX:+G1UsePreventiveGC`.