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

Stefan Johansson sjohanss at openjdk.java.net
Wed Nov 4 11:39:04 UTC 2020


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.

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

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

Changes: https://git.openjdk.java.net/jdk/pull/1051/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=1051&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8255848
  Stats: 2 lines in 1 file changed: 1 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/1051.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/1051/head:pull/1051

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



More information about the hotspot-gc-dev mailing list