RFR: 8238687: Investigate memory uncommit during young collections in G1 [v11]

Kim Barrett kbarrett at openjdk.org
Mon Jul 7 22:04:43 UTC 2025


On Wed, 2 Jul 2025 07:00:35 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

>> src/hotspot/share/gc/g1/g1CollectedHeap.cpp line 894:
>> 
>>> 892: 
>>> 893:   bool should_expand;
>>> 894:   size_t resize_bytes = _heap_sizing_policy->full_collection_resize_amount(should_expand, allocation_word_size);
>> 
>> pre-existing:  I wonder why this isn't a function that returns a `ptrdiff_t` delta on the current size,
>> removing the need for multiple values, one being returned via a by-reference out parameter.
>> Similarly for the young collection case. Or return the size & direction as a pair-like object.
>> (Personally, I find by-reference out parameters confusing to read, but maybe that's just me.)
>
> One potential reason: on 32 bit platforms `ptrdiff_t` is +- 2GB. Heap can be ~4GB on Linux, so `ptrdiff_t` could not represent all potential resize sizes.

Oh, right you are!

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25832#discussion_r2191067844


More information about the hotspot-dev mailing list