Skip to content

Commit 491d43c

Browse files
committed
8289838: ZGC: OOM before clearing all SoftReferences
Reviewed-by: ayang, tschatzl
1 parent a1c349f commit 491d43c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/hotspot/share/gc/z/zHeap.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ void ZHeap::mark_start() {
225225
// Verification
226226
ClassLoaderDataGraph::verify_claimed_marks_cleared(ClassLoaderData::_claim_strong);
227227

228+
if (ZHeap::heap()->has_alloc_stalled()) {
229+
// If there are stalled allocations, ensure that regardless of the
230+
// cause of the GC, we have to clear soft references, as we are just
231+
// about to increment the sequence number, and all previous allocations
232+
// will throw if not presented with enough memory.
233+
ZHeap::heap()->set_soft_reference_policy(true);
234+
}
235+
228236
// Flip address view
229237
flip_to_marked();
230238

0 commit comments

Comments
 (0)