RFR: 8357086: os::xxx functions returning memory size should return size_t [v23]
David Holmes
dholmes at openjdk.org
Mon Aug 4 07:44:06 UTC 2025
On Fri, 1 Aug 2025 09:19:55 GMT, Anton Artemov <duke at openjdk.org> wrote:
>> Hi,
>>
>> in this PR the output value types for functions which return memory are changed, namely:
>>
>>
>> static julong available_memory(); --> static bool available_memory(size_t& value);
>> static julong used_memory(); --> static bool used_memory(size_t& value);
>> static julong free_memory(); --> static bool free_memory(size_t& value);
>> static jlong total_swap_space(); --> static bool total_swap_space(size_t& value);
>> static jlong free_swap_space(); --> static bool free_swap_space(size_t& value);
>> static julong physical_memory(); --> static size_t physical_memory(size_t& value);
>>
>>
>> The return boolean value, where available, indicates success, whereas the actual value is assigned to the input argument. The following recommended usage pattern is introduced: where applicable, and unsuccessful call is logged.
>>
>> `ATTRIBUTE_NODISCARD` macro is added as a placeholder for `[[nodiscard]]`, which will be available with C++17.
>>
>> Tested in GHA and Tiers 1-5.
>
> Anton Artemov has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 24 commits:
>
> - 8357086: Fixed merge conflict
> - 8357086: Removed extra line
> - 8357086: Made physical_memory() return size_t, added dummy ATTRIBUTE_NODISCARD
> - 8357086: Small fixes
> - 8357086: Made physical_memory() return void
> - 8357086: Fixed behavior of total_swap_space on Linux
> - 8357086: Addressed reviewer's comments.
> - 8357086: Fixed void conversion.
> - 8357086: Addressed reviewer's comments
> - 8357086: Addressed reviewer's comments
> - ... and 14 more: https://git.openjdk.org/jdk/compare/d80b5c87...f9b2c6d8
src/hotspot/share/runtime/arguments.cpp line 1507:
> 1505: void Arguments::set_heap_size() {
> 1506: julong phys_mem;
> 1507: size_t physical_mem_val = 0;
I'm not seeing why you needed to introduce this as a temporary. ??
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25450#discussion_r2250670601
More information about the hotspot-dev
mailing list