Skip to content

Commit f1220e4

Browse files
expirements
1 parent ff81eb2 commit f1220e4

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

Include/internal/pycore_gc.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ static inline void _PyObject_GC_TRACK(
240240

241241
PyInterpreterState *interp = _PyInterpreterState_GET();
242242
PyGC_Head *generation0 = &interp->gc.young.head;
243+
interp->gc.young.count++;
243244
PyGC_Head *last = (PyGC_Head*)(generation0->_gc_prev);
244245
_PyGCHead_SET_NEXT(last, gc);
245246
_PyGCHead_SET_PREV(gc, last);
@@ -281,6 +282,11 @@ static inline void _PyObject_GC_UNTRACK(
281282
gc->_gc_next = 0;
282283
gc->_gc_prev &= _PyGC_PREV_MASK_FINALIZED;
283284
#endif
285+
286+
PyInterpreterState *interp = _PyInterpreterState_GET();
287+
if (interp->gc.young.count > 0) {
288+
interp->gc.young.count--;
289+
}
284290
}
285291

286292

Python/gc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,7 +2108,7 @@ _PyGC_Collect(PyThreadState *tstate, int generation, _PyGC_Reason reason)
21082108
if (reason != _Py_GC_REASON_SHUTDOWN) {
21092109
invoke_gc_callback(gcstate, "stop", generation, &stats);
21102110
}
2111-
else {
2111+
else if (false) {
21122112
FILE *out = stderr;
21132113

21142114
fprintf(out, "GC[%d] total tuples : %zd\n", 0, gcstate->generation_stats[0].total_tuples);
@@ -2316,7 +2316,7 @@ _PyObject_GC_Link(PyObject *op)
23162316
GCState *gcstate = &tstate->interp->gc;
23172317
gc->_gc_next = 0;
23182318
gc->_gc_prev = 0;
2319-
gcstate->young.count++; /* number of allocated GC objects */
2319+
//gcstate->young.count++; /* number of allocated GC objects */
23202320
gcstate->heap_size++;
23212321
if (gcstate->young.count > gcstate->young.threshold &&
23222322
gcstate->enabled &&
@@ -2448,9 +2448,9 @@ PyObject_GC_Del(void *op)
24482448
#endif
24492449
}
24502450
GCState *gcstate = get_gc_state();
2451-
if (gcstate->young.count > 0) {
2452-
gcstate->young.count--;
2453-
}
2451+
//if (gcstate->young.count > 0) {
2452+
// gcstate->young.count--;
2453+
//}
24542454
gcstate->heap_size--;
24552455
PyObject_Free(((char *)op)-presize);
24562456
}

0 commit comments

Comments
 (0)