Skip to content

Commit 866bd56

Browse files
committed
Account for marked objects in candidates.
1 parent 7f46627 commit 866bd56

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Python/gc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,7 @@ gc_collect_increment(PyThreadState *tstate, struct gc_collection_stats *stats)
16671667
Py_ssize_t objects_marked = mark_at_start(tstate);
16681668
GC_STAT_ADD(1, objects_transitively_reachable, objects_marked);
16691669
gcstate->work_to_do -= objects_marked;
1670+
stats->candidates += objects_marked;
16701671
validate_spaces(gcstate);
16711672
return;
16721673
}

Python/gc_free_threading.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -982,18 +982,18 @@ update_refs(const mi_heap_t *heap, const mi_heap_area_t *area,
982982
return true;
983983
}
984984

985-
if (gc_is_alive(op)) {
986-
return true;
987-
}
988-
989985
// Exclude immortal objects from garbage collection
990986
if (_Py_IsImmortal(op)) {
991987
op->ob_tid = 0;
992988
_PyObject_GC_UNTRACK(op);
993989
gc_clear_unreachable(op);
994990
return true;
995991
}
992+
// Marked objects count as candidates, immortals don't:
996993
state->candidates++;
994+
if (gc_is_alive(op)) {
995+
return true;
996+
}
997997

998998
Py_ssize_t refcount = Py_REFCNT(op);
999999
if (_PyObject_HasDeferredRefcount(op)) {

0 commit comments

Comments
 (0)