File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff 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 ++ ; /* number of tracked GC objects */
243244 PyGC_Head * last = (PyGC_Head * )(generation0 -> _gc_prev );
244245 _PyGCHead_SET_NEXT (last , gc );
245246 _PyGCHead_SET_PREV (gc , last );
@@ -280,6 +281,10 @@ static inline void _PyObject_GC_UNTRACK(
280281 _PyGCHead_SET_PREV (next , prev );
281282 gc -> _gc_next = 0 ;
282283 gc -> _gc_prev &= _PyGC_PREV_MASK_FINALIZED ;
284+ PyInterpreterState * interp = _PyInterpreterState_GET ();
285+ if (interp -> gc .young .count > 0 ) {
286+ interp -> gc .young .count -- ;
287+ }
283288#endif
284289}
285290
Original file line number Diff line number Diff line change @@ -2296,7 +2296,6 @@ _PyObject_GC_Link(PyObject *op)
22962296 GCState * gcstate = & tstate -> interp -> gc ;
22972297 gc -> _gc_next = 0 ;
22982298 gc -> _gc_prev = 0 ;
2299- gcstate -> young .count ++ ; /* number of allocated GC objects */
23002299 gcstate -> heap_size ++ ;
23012300 if (gcstate -> young .count > gcstate -> young .threshold &&
23022301 gcstate -> enabled &&
@@ -2428,9 +2427,6 @@ PyObject_GC_Del(void *op)
24282427#endif
24292428 }
24302429 GCState * gcstate = get_gc_state ();
2431- if (gcstate -> young .count > 0 ) {
2432- gcstate -> young .count -- ;
2433- }
24342430 gcstate -> heap_size -- ;
24352431 PyObject_Free (((char * )op )- presize );
24362432}
You can’t perform that action at this time.
0 commit comments