[PATCH] JDK-23: Fix for relocation set selecting in ZGC

Axel Boldt-Christmas axel.boldt-christmas at oracle.com
Thu Oct 9 09:56:22 UTC 2025


Hi,

When you say that this causes ZGC to fail promotion. Do you mean that we do not select pages causing “memory leaks” because of fragmentation which larger than the ZYoungCompactionLimit? (And did you also mean old to old relocation selection?)

The selection code was taken from non-generational ZGC. So it also a bit inaccurate because it does not understand that promotions can only age the an object by one and we track age on a heap region basis.

I have a couple of branches where I worked on prototypes for improving this: https://github.com/openjdk/jdk/compare/master...xmas92:jdk:relocation_set_selection_cleanups
(Which also aims to fixe the mismatch in the logs which you have observed.)

I was aware that our logic is fuzzy and that we have a mismatch in our logging. But I did not think we “failed to promote objects”. Maybe you can elaborate what you mean by this.

Thanks in advance,
Axel Boldt-Christmas


On 9 Oct 2025, at 11:16, yifan zhang <yifanzhang765 at gmail.com> wrote:

Hi ZGC Developers,

I've encountered an issue where ZGC might fail to promote objects under a specific condition, leading to a memory leak. This patch aims to fix it.

* Problem:
  The number of selected pages in the ZGC log is incorrect.

* Fix:
  The root cause lies in the execution of function ZRelocationSetSelectorGroup::select_inner, where the count of selected pages only includes the pages that satisfy the condition diff_reclaimable > _fragmentation_limit, while ignoring the previously accumulated pages.
  This results in a mismatch between the number of pages actually reclaimed during relocation and the count reflected in the log.
  I have attached my modifications in the attachment.

* Testing:
  I've tested this fix by jtreg.




I would like to ask ZGC developers to review whether this can be created as an issue. Once it is created, how should I commit my modifications for it? Furthermore, how can I become an OpenJDK author?
Please help to review this patch. Any feedback is appreciated.

Thanks,

Yifan Zhang

<zgc_fix.patch>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/zgc-dev/attachments/20251009/add956e4/attachment-0001.htm>


More information about the zgc-dev mailing list