--- old/src/hotspot/share/gc/g1/g1VMOperations.cpp 2019-11-06 19:09:41.531658289 -0500 +++ new/src/hotspot/share/gc/g1/g1VMOperations.cpp 2019-11-06 19:09:41.283644989 -0500 @@ -72,8 +72,13 @@ // to notify the caller and return immediately. _cycle_already_in_progress = true; } else if (!g1h->do_collection_pause_at_safepoint(_target_pause_time_ms)) { + // Failure to perform the collection at all occurs because GCLocker is + // active, and we have the bad luck to be the collection request that + // makes a later _gc_locker collection needed. (Else we would have hit + // the GCLocker check in the prologue.) _transient_failure = true; } else if (g1h->should_upgrade_to_full_gc(_gc_cause)) { + // GC ran, but we're still in trouble and need a full GC. log_info(gc, ergo)("Attempting maximally compacting collection"); _gc_succeeded = g1h->do_full_collection(false, /* explicit gc */ true /* clear_all_soft_refs */); @@ -121,17 +126,13 @@ // An allocation had been requested. Do it, eventually trying a stronger // kind of GC. _result = g1h->satisfy_failed_allocation(_word_size, &_gc_succeeded); - } else { - bool should_upgrade_to_full = g1h->should_upgrade_to_full_gc(_gc_cause); - - 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"); - _gc_succeeded = g1h->do_full_collection(false, /* explicit gc */ - true /* clear_all_soft_refs */); - } + } else if (g1h->should_upgrade_to_full_gc(_gc_cause)) { + // 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"); + _gc_succeeded = g1h->do_full_collection(false, /* explicit gc */ + true /* clear_all_soft_refs */); } guarantee(_gc_succeeded, "Elevated collections during the safepoint must always succeed."); }