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

Anton Artemov duke at openjdk.org
Wed Jul 30 09:19:22 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 bool physical_memory(size_t& value); 
> 
> 
> The return boolean value 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. 
> 
> Later, the return value can be attributed with `[[nodiscard]]` to enforce the pattern.
> 
> 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 incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 13 additional commits since the last revision:

 - Merge remote-tracking branch 'origin/master' into JDK-8357086_size_t_memfuncs
 - 8357086: Fxied return value
 - 8357086: Fixed whitespaces
 - 8357086: Introduced usage pattern
 - 8357086: Fixed typo
 - 8357086: Refactored physical_memory in different OS
 - 8357086: Small fixes 2
 - 8357086: Small fixes 1.
 - 8357086: Refactored physical_memory()
 - 8357086: Refactored free_swap_space()
 - ... and 3 more: https://git.openjdk.org/jdk/compare/7b9a701a...372593b4

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/25450/files
  - new: https://git.openjdk.org/jdk/pull/25450/files/e4698333..372593b4

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

  Stats: 60433 lines in 1772 files changed: 32969 ins; 17475 del; 9989 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