JDK-8308854 : G1 archive region allocation may expand/shrink the heap above/below -Xms
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 21
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-05-25
  • Updated: 2025-05-21
  • Resolved: 2025-05-12
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 25
25 b23Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
When loading archive regions in G1, it always uses the regions at highest addresses for CDS archives, committing regions as needed.

Since the Java heap is allocated from lowest to highest, this results in more memory than -Xms used by G1.

This is day one behavior, not sure if that has been intended, so starting off with an RFE.
Comments
Changeset: a3afc9f7 Branch: master Author: Ivan Walulya <iwalulya@openjdk.org> Date: 2025-05-12 08:15:53 +0000 URL: https://git.openjdk.org/jdk/commit/a3afc9f7ceba24ab607141426bb0a2693e6d37ca
12-05-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/25036 Date: 2025-05-05 12:29:02 +0000
05-05-2025

Most likely be fixed with JDK-8326035
09-10-2024

The other issue is that if -Xms==-Xmx, deallocation of archive regions intermittently makes the heap go below -Xms.
02-06-2023

The impact is that G1 briefly commits more initial heap memory than expected (keeping -Xmx). Since initial heap memory isn't guaranteed at entry to the main method, this is not really a "bug", but maybe somewhat unexpected behavior with CDS
26-05-2023