RFR: 8255848: -Xlog:gc+heap+exit shows "used 0K"

Thomas Schatzl tschatzl at openjdk.java.net
Wed Nov 4 11:57:55 UTC 2020


On Wed, 4 Nov 2020 11:29:06 GMT, Stefan Johansson <sjohanss at openjdk.org> wrote:

> Please review this small change to improve the exit heap-log for G1.
> 
> Currently if all allocations fit into one region the exit log will faulty state that the usage is 0K:
> $ java -Xlog:gc+heap+exit -Xshare:off -Xmx16g -version
> [0.072s][info][gc,heap,exit] garbage-first heap total 1032192K, used 0K [0x00000003c0000000, 0x00000007c0000000)
> [0.072s][info][gc,heap,exit] region size 8192K, 1 young (8192K), 0 survivors (0K)
> 
> This is cause by G1 using `used_unlocked()`, which doesn't take the current allocation region(s) into account. My proposed change is to check if the `Heap_lock` is taken and if so use `used()` instead of `used_unlocked()`. For the exit logging the lock will be held, but this log is printed using `G1CollectedHeap::print_on()` and we might want to allow calling this without requiring holding the heap lock.

lgtm.

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

Marked as reviewed by tschatzl (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/1051



More information about the hotspot-gc-dev mailing list