8255848: -Xlog:gc+heap+exit shows "used 0K"
Reviewed-by: tschatzl, ayang
diff --git a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp
index d440013..3b77b9b 100644
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp
@@ -2437,10 +2437,11 @@
}
void G1CollectedHeap::print_on(outputStream* st) const {
+ size_t heap_used = Heap_lock->owned_by_self() ? used() : used_unlocked();
st->print(" %-20s", "garbage-first heap");
if (_hrm != NULL) {
st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K",
- capacity()/K, used_unlocked()/K);
+ capacity()/K, heap_used/K);
st->print(" [" PTR_FORMAT ", " PTR_FORMAT ")",
p2i(_hrm->reserved().start()),
p2i(_hrm->reserved().end()));