Fix a reference cycle by triggering an explicit GC collection
after calling PyInterpreterState_Clear().
/* Clear interpreter state and all thread states */
PyInterpreterState_Clear(tstate->interp);
- /* Trigger a GC collection on subinterpreters*/
- if (!is_main_interp) {
- _PyGC_CollectNoFail();
- }
+ /* Last explicit GC collection */
+ _PyGC_CollectNoFail();
/* Clear all loghooks */
/* Both _PySys_Audit function and users still need PyObject, such as tuple.