RFR: 8308854: G1 archive region allocation may expand/shrink the heap above/below -Xms

Thomas Schatzl tschatzl at openjdk.org
Tue May 6 08:19:17 UTC 2025


On Mon, 5 May 2025 12:29:02 GMT, Ivan Walulya <iwalulya at openjdk.org> wrote:

> Hi,
> 
> Please review this change to prevent G1 from shrinking the heap below -Xms when deallocating CDS archive regions. This issue is particularly noticeable when -Xms==-Xmx, G1 still uncommits the archive regions thus shrinking the heap below -Xms. In this change, G1 does not uncommit the archive regions in cases where doing so would shrink the heap below the configured -Xms.
> 
> This is a temporary fix, we expect a more complete solution to be delivered under [JDK-8326035](https://bugs.openjdk.org/browse/JDK-8326035).
> 
> Testing: gha, manual testing as below:
> 
> Mainline:
> 
> 
> [3.740s][info ][gc,init     ] Heap Min Capacity: 150G
> [3.740s][info ][gc,init     ] Heap Initial Capacity: 150G
> [3.740s][info ][gc,init     ] Heap Max Capacity: 150G
> .
> .
> [3.749s][debug][gc,ergo,heap] Attempt heap shrinking (CDS archive regions). Total size: 33554432B
> .
> .
> [9.000s][info ][gc          ] GC(0) Pause Full (System.gc()) 10728M->140M(153568M) 119.887ms
> 
> With patch (No shrinking when -Xms == -Xms):
> 
> 
> [3.753s][info ][gc,init     ] Heap Min Capacity: 150G
> [3.753s][info ][gc,init     ] Heap Initial Capacity: 150G
> [3.753s][info ][gc,init     ] Heap Max Capacity: 150G
> .
> .
> [8.773s][info ][gc          ] GC(0) Pause Full (System.gc()) 10687M->140M(153600M) 117.901ms
> 
> With patch (Shrinking when -Xms != -Xms):
> 
> 
> [3.755s][info ][gc,init     ] Heap Min Capacity: 153568M
> [3.755s][info ][gc,init     ] Heap Initial Capacity: 153568M
> [3.755s][info ][gc,init     ] Heap Max Capacity: 150G
> .
> .
> [3.764s][debug][gc,ergo,heap] Attempt heap shrinking (CDS archive regions). Total size: 33554432B (1 Regions)
> .
> .
> [8.919s][info ][gc          ] GC(0) Pause Full (System.gc()) 10692M->140M(153568M) 125.810ms

Marked as reviewed by tschatzl (Reviewer).

-------------

PR Review: https://git.openjdk.org/jdk/pull/25036#pullrequestreview-2817316832


More information about the hotspot-gc-dev mailing list