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

Stefan Johansson sjohanss at
Thu Nov 5 08:16:55 UTC 2020

On Wed, 4 Nov 2020 11:29:06 GMT, Stefan Johansson <sjohanss at> 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.

This pull request has now been integrated.

Changeset: 397972eb
Author:    Stefan Johansson <sjohanss at>
Stats:     2 lines in 1 file changed: 1 ins; 0 del; 1 mod

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

Reviewed-by: tschatzl, ayang



More information about the hotspot-gc-dev mailing list