< prev index next >

src/share/vm/gc/g1/g1CollectedHeap.cpp

Print this page
rev 10739 : 8153745: Avoid spawning G1ParPreserveCMReferentsTask when there is no work to be done
Reviewed-by:
rev 10740 : [mq]: check-during-cycle

@@ -4460,11 +4460,15 @@
   // objects discovered by the STW ref processor in case one of these
   // referents points to another object which is also referenced by an
   // object discovered by the STW ref processor.
   double preserve_cm_referents_time = 0.0;
 
-  if (_ref_processor_cm->has_discovered_references()) {
+  // To avoid spawning task when there is no work to do, check that
+  // a concurrent cycle is active and that some references have been
+  // discovered.
+  if (concurrent_mark()->cmThread()->during_cycle() &&
+      ref_processor_cm()->has_discovered_references()) {
     double preserve_cm_referents_start = os::elapsedTime();
     uint no_of_gc_workers = workers()->active_workers();
     G1ParPreserveCMReferentsTask keep_cm_referents(this,
                                                    per_thread_states,
                                                    no_of_gc_workers,
< prev index next >