--- old/src/share/vm/gc/g1/g1CollectedHeap.cpp 2015-08-19 16:55:22.977782202 -0400 +++ new/src/share/vm/gc/g1/g1CollectedHeap.cpp 2015-08-19 16:55:21.661706728 -0400 @@ -1774,6 +1774,14 @@ return result; } + // We may shrink heap too much after full gc. + // Expand heap will help - JDK-8130265 + result = expand_and_allocate(word_size, context); + if (result != NULL) { + assert(*succeeded, "sanity"); + return result; + } + // Then, try a Full GC that will collect all soft references. gc_succeeded = do_collection(false, /* explicit_gc */ true, /* clear_all_soft_refs */ @@ -1795,6 +1803,13 @@ assert(!collector_policy()->should_clear_all_soft_refs(), "Flag should have been handled and cleared prior to this point"); + // Retry expand_and_allocate once more + result = expand_and_allocate(word_size, context); + if (result != NULL) { + assert(*succeeded, "sanity"); + return result; + } + // What else? We might try synchronous finalization later. If the total // space available is large enough for the allocation, then a more // complete compaction phase than we've tried so far might be