RFR: 8352765: G1CollectedHeap::expand_and_allocate() may fail to allocate even after heap expansion succeeds [v2]

Ivan Walulya iwalulya at openjdk.org
Fri Mar 28 13:09:09 UTC 2025


On Fri, 28 Mar 2025 06:49:04 GMT, Man Cao <manc at openjdk.org> wrote:

> I just have a two questions, which probably does not need to be addressed in this PR.
> 
>     1. Is it possible for `expand_and_allocate()` to run into the [`receiving_additional_eden = 0;`](https://github.com/openjdk/jdk/blob/2ea1557a0fdaf551d75365d1351bfbd73319dcfb/src/hotspot/share/gc/g1/g1Policy.cpp#L320) situation under the `if (allocated_young_length >= desired_young_length)` branch?
> 
>     2. It feels like G1 should recalculate young list length parameters after a successful `expand()` or `shrink()`. Currently `G1Policy::record_new_heap_size()` only recalculates the min/max young lengths. Is it reasonable to run `calculate_young_desired_length()` and `calculate_young_target_length()` inside `G1Policy::record_new_heap_size()`?

Yes, I think we need to do the recalculation after expand as the expansion changes the number of free regions available and so should affect the young_[desired,target]_lengths. Otherwise, it is possible to expand and fail allocation. This can be addressed in a separate PR though.

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

PR Comment: https://git.openjdk.org/jdk/pull/24257#issuecomment-2761316156


More information about the hotspot-gc-dev mailing list