src/hotspot/share/gc/g1/vm_operations_g1.cpp
changeset 48638 01094f78d990
parent 48631 862c41cf1c7f
child 49323 565336327354
--- a/src/hotspot/share/gc/g1/vm_operations_g1.cpp	Sat Jan 13 02:56:22 2018 +0100
+++ b/src/hotspot/share/gc/g1/vm_operations_g1.cpp	Wed Jan 17 19:05:58 2018 +0100
@@ -139,13 +139,17 @@
       // An allocation had been requested. Do it, eventually trying a stronger
       // kind of GC.
       _result = g1h->satisfy_failed_allocation(_word_size, _allocation_context, &_pause_succeeded);
-    } else if (!g1h->has_regions_left_for_allocation()) {
-      // There has been a request to perform a GC to free some space. We have no
-      // information on how much memory has been asked for. In case there are
-      // absolutely no regions left to allocate into, do a maximally compacting full GC.
-      log_info(gc, ergo)("Attempting maximally compacting collection");
-      _pause_succeeded = g1h->do_full_collection(false, /* explicit gc */
-                                                 true   /* clear_all_soft_refs */);
+    } else {
+      bool should_upgrade_to_full = !g1h->should_do_concurrent_full_gc(_gc_cause) &&
+                                    !g1h->has_regions_left_for_allocation();
+      if (should_upgrade_to_full) {
+        // There has been a request to perform a GC to free some space. We have no
+        // information on how much memory has been asked for. In case there are
+        // absolutely no regions left to allocate into, do a maximally compacting full GC.
+        log_info(gc, ergo)("Attempting maximally compacting collection");
+        _pause_succeeded = g1h->do_full_collection(false, /* explicit gc */
+                                                   true   /* clear_all_soft_refs */);
+      }
     }
     guarantee(_pause_succeeded, "Elevated collections during the safepoint must always succeed.");
   } else {