RFR: 8357086: os::xxx functions returning memory size should return size_t [v22]

Anton Artemov duke at openjdk.org
Fri Aug 1 09:11:54 UTC 2025


> 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 incrementally with two additional commits since the last revision:

 - 8357086: Removed extra line
 - 8357086: Made physical_memory() return size_t, added dummy ATTRIBUTE_NODISCARD

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/25450/files
  - new: https://git.openjdk.org/jdk/pull/25450/files/22c752c2..ab62a520

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=25450&range=21
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=25450&range=20-21

  Stats: 50 lines in 14 files changed: 5 ins; 15 del; 30 mod
  Patch: https://git.openjdk.org/jdk/pull/25450.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/25450/head:pull/25450

PR: https://git.openjdk.org/jdk/pull/25450


More information about the hotspot-dev mailing list