@@ -1090,20 +1090,9 @@ record_deallocation(PyThreadState *tstate)
10901090}
10911091
10921092static void
1093- gc_collect_internal (PyInterpreterState * interp , struct collection_state * state , int generation )
1093+ gc_collect_internal (PyInterpreterState * interp , struct collection_state * state )
10941094{
10951095 _PyEval_StopTheWorld (interp );
1096-
1097- // update collection and allocation counters
1098- if (generation + 1 < NUM_GENERATIONS ) {
1099- state -> gcstate -> old [generation ].count += 1 ;
1100- }
1101-
1102- state -> gcstate -> young .count = 0 ;
1103- for (int i = 1 ; i <= generation ; ++ i ) {
1104- state -> gcstate -> old [i - 1 ].count = 0 ;
1105- }
1106-
11071096 // merge refcounts for all queued objects
11081097 merge_all_queued_objects (interp , state );
11091098 process_delayed_frees (interp );
@@ -1169,6 +1158,7 @@ gc_collect_internal(PyInterpreterState *interp, struct collection_state *state,
11691158static Py_ssize_t
11701159gc_collect_main (PyThreadState * tstate , int generation , _PyGC_Reason reason )
11711160{
1161+ int i ;
11721162 Py_ssize_t m = 0 ; /* # objects collected */
11731163 Py_ssize_t n = 0 ; /* # unreachable objects that couldn't be collected */
11741164 PyTime_t t1 = 0 ; /* initialize to prevent a compiler warning */
@@ -1215,14 +1205,23 @@ gc_collect_main(PyThreadState *tstate, int generation, _PyGC_Reason reason)
12151205 PyDTrace_GC_START (generation );
12161206 }
12171207
1208+ /* update collection and allocation counters */
1209+ if (generation + 1 < NUM_GENERATIONS ) {
1210+ gcstate -> old [generation ].count += 1 ;
1211+ }
1212+ gcstate -> young .count = 0 ;
1213+ for (i = 1 ; i <= generation ; i ++ ) {
1214+ gcstate -> old [i - 1 ].count = 0 ;
1215+ }
1216+
12181217 PyInterpreterState * interp = tstate -> interp ;
12191218
12201219 struct collection_state state = {
12211220 .interp = interp ,
12221221 .gcstate = gcstate ,
12231222 };
12241223
1225- gc_collect_internal (interp , & state , generation );
1224+ gc_collect_internal (interp , & state );
12261225
12271226 m = state .collected ;
12281227 n = state .uncollectable ;
0 commit comments