RFR: 8334489: Add function os::used_memory [v2]

Thomas Stuefe stuefe at openjdk.org
Thu Jun 20 11:25:15 UTC 2024


On Wed, 19 Jun 2024 20:27:13 GMT, Erik Österlund <eosterlund at openjdk.org> wrote:

>> src/hotspot/share/runtime/os.hpp line 341:
>> 
>>> 339: #ifdef LINUX
>>> 340:   static julong used_memory();
>>> 341: #endif
>> 
>> I don't understand. Now it's a linux only API? Wasn't the intention to have it available on all, but a shared impl for all except Linux, like in `os.cpp`?
>> 
>> Something like:
>> 
>> LINUX_ONLY(static julong pd_used_memory();)
>> ...
>> julong os::used_memory() {
>> #ifdef LINUX
>>   return os::pd_used_memory();
>> #else
>>   return os::physical_memory() - os::available_memory();
>> #endif
>> }
>
>> I don't understand. Now it's a linux only API? Wasn't the intention to have it available on all, but a shared impl for all except Linux, like in `os.cpp`?
>> 
>> 
>> 
>> Something like:
>> 
>> ```
>> 
>> LINUX_ONLY(static julong pd_used_memory();)
>> 
>> ...
>> 
>> julong os::used_memory() {
>> 
>> #ifdef LINUX
>> 
>>   return os::pd_used_memory();
>> 
>> #else
>> 
>>   return os::physical_memory() - os::available_memory();
>> 
>> #endif
>> 
>> }
> 
> That was indeed the intention.

Would have thought that too.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19772#discussion_r1646961676


More information about the hotspot-runtime-dev mailing list