RFR: 8222462: Introduce CollectedHeap::unused()

Erik Österlund erik.osterlund at oracle.com
Tue Apr 23 08:13:27 UTC 2019


Hi Per,

Perhaps we need a cleanup of racy accesses that should use Atomic to 
make the code more future-proof. But I'm cool with deferring that until 
later as this is already a problem in the code in other places.

Looks good.

Thanks,
/Erik

On 2019-04-17 10:39, Per Liden wrote:
> Did an off-line review with Stefan. Added a comment and a minor tweak 
> to the ZGC part.
>
> Updated webrev: http://cr.openjdk.java.net/~pliden/8222462/webrev.1
>
> /Per
>
>
> On 04/15/2019 08:49 AM, Per Liden wrote:
>> JVM_FreeMemory() has two problems:
>>
>> 1) It currently uses Heap_lock to protect capacity() and used() from 
>> changing while calculating the amount of free memory available. 
>> However, Heap_lock is doesn't protect capacity() and used() in all 
>> collectors, and as a result, JVM_FreeMemory() could return a negative 
>> value.
>>
>> 2) The amount of free memory is not always calculated using 
>> capacity() - used(). For ZGC, we also want to take the reserve into 
>> account.
>>
>> The proposed solution is to introduce CollectedHeap::unused() (the 
>> name is chosen to match CollectedHeap::used()), so that we can 
>> delegate this calculation to the GC.
>>
>> Testing: tier1-3
>>
>> Bug: https://bugs.openjdk.java.net/browse/JDK-8222462
>> Webrev: http://cr.openjdk.java.net/~pliden/8222462/webrev.0
>>
>> /Per




More information about the hotspot-gc-dev mailing list