RFR: 8364248: Separate memory limit detection [v3]
Joel Sikström
jsikstro at openjdk.org
Wed Jul 30 09:35:52 UTC 2025
On Tue, 29 Jul 2025 14:34:32 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:
>> Joel Sikström has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Rename os::has_allocatable_memory_limit() to os::allocatable_memory_limit()
>
> src/hotspot/os/posix/os_posix.cpp line 738:
>
>> 736: // On POSIX systems, the amount of allocatable memory is limited by the
>> 737: // size of the virtual address space.
>> 738: *limit = address_space_limit();
>
> In @toxaart's PR the out parameter is never set if the return value is false. I think the reason why that was done was so that code could be written like this:
>
> size_t value = 0;
> if (os::memory_function(value)) {
> // Succeeded - do stuff
> } else {
> // Failed - do other stuff
> }
>
> // Use 0 if the function returned an error
> use(value);
>
>
> I think we should strive for unification around that in the various os:: memory functions. I also think that he used `&` in his patch and this function uses a pointer with the output parameter. Unification around would be good as well.
Sounds good. I'll change to using a reference instead of a pointer and only set the out-parameter if we return true.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26530#discussion_r2242063296
More information about the hotspot-gc-dev
mailing list