diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index f7c53a7187350c66f255d1a86f1532e8827f215a..4f2ef1d5d78f1db4273b611aa60c3be99438bf94 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -1666,6 +1666,11 @@ size_t G1CollectedHeap::used() const { return result; } +size_t G1CollectedHeap::used_unlocked() const { + size_t result = _summary_bytes_used; + return result; +} + class SumUsedClosure: public HeapRegionClosure { size_t _used; public: @@ -2349,7 +2354,7 @@ void G1CollectedHeap::print_on(outputStream* st) const { void G1CollectedHeap::print_on(outputStream* st, bool extended) const { st->print(" %-20s", "garbage-first heap"); st->print(" total " SIZE_FORMAT "K, used " SIZE_FORMAT "K", - capacity()/K, used()/K); + capacity()/K, used_unlocked()/K); st->print(" [" INTPTR_FORMAT ", " INTPTR_FORMAT ", " INTPTR_FORMAT ")", _g1_storage.low_boundary(), _g1_storage.high(), diff --git a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp index 3dc60175986fefd36b4673fb2c83b9cfd574abde..2bf8b51299c9b38c0e482da422acc4c2ab9fbea9 100644 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @@ -700,6 +700,9 @@ public: size_t g1_reserved_obj_bytes() { return _g1_reserved.byte_size(); } virtual size_t capacity() const; virtual size_t used() const; + // This should be called when we're not holding the heap lock. The + // result might be a bit inaccurate. + size_t used_unlocked() const; size_t recalculate_used() const; #ifndef PRODUCT size_t recalculate_used_regions() const;