File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
src/hotspot/share/gc/shenandoah Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -809,12 +809,22 @@ HeapWord* ShenandoahHeap::allocate_memory(ShenandoahAllocRequest& req) {
809
809
// way later after GC happened, only to fail the second allocation, because
810
810
// other threads have already depleted the free storage. In this case, a better
811
811
// strategy is to try again, as long as GC makes progress.
812
+ //
813
+ // Then, we need to make sure the allocation was retried after at least one
814
+ // Full GC, which means we want to try more than ShenandoahFullGCThreshold times.
815
+
816
+ size_t tries = 0 ;
817
+
818
+ while (result == NULL && _progress_last_gc.is_set ()) {
819
+ tries++;
820
+ control_thread ()->handle_alloc_failure (req.size ());
821
+ result = allocate_memory_under_lock (req, in_new_region);
822
+ }
812
823
813
- if (result == NULL ) {
814
- do {
815
- control_thread ()->handle_alloc_failure (req.size ());
816
- result = allocate_memory_under_lock (req, in_new_region);
817
- } while (result == NULL && _progress_last_gc.is_set ());
824
+ while (result == NULL && tries <= ShenandoahFullGCThreshold) {
825
+ tries++;
826
+ control_thread ()->handle_alloc_failure (req.size ());
827
+ result = allocate_memory_under_lock (req, in_new_region);
818
828
}
819
829
820
830
} else {
You can’t perform that action at this time.
0 commit comments