src/hotspot/share/gc/g1/g1CollectedHeap.cpp
changeset 51694 0dca9b29bf30
parent 51625 c265860d5d45
child 51796 9d3a00c8c047
--- a/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Tue Sep 11 09:27:47 2018 +0800
+++ b/src/hotspot/share/gc/g1/g1CollectedHeap.cpp	Tue Sep 11 09:13:37 2018 +0200
@@ -1950,12 +1950,8 @@
 };
 
 size_t G1CollectedHeap::recalculate_used() const {
-  double recalculate_used_start = os::elapsedTime();
-
   SumUsedClosure blk;
   heap_region_iterate(&blk);
-
-  g1_policy()->phase_times()->record_evac_fail_recalc_used_time((os::elapsedTime() - recalculate_used_start) * 1000.0);
   return blk.result();
 }
 
@@ -3013,7 +3009,10 @@
         g1_policy()->phase_times()->record_start_new_cset_time_ms((os::elapsedTime() - start) * 1000.0);
 
         if (evacuation_failed()) {
+          double recalculate_used_start = os::elapsedTime();
           set_used(recalculate_used());
+          g1_policy()->phase_times()->record_evac_fail_recalc_used_time((os::elapsedTime() - recalculate_used_start) * 1000.0);
+
           if (_archive_allocator != NULL) {
             _archive_allocator->clear_used();
           }