bpo-1635741: Explict GC collect after PyInterpreterState_Clear() (GH-21902)

Fix a reference cycle by triggering an explicit GC collection
after calling PyInterpreterState_Clear().
This commit is contained in:
Hai Shi 2020-08-18 04:36:19 +08:00 committed by GitHub
parent 29f84294d8
commit 8aa163eea6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions

View File

@ -1286,10 +1286,8 @@ finalize_interp_clear(PyThreadState *tstate)
/* Clear interpreter state and all thread states */
PyInterpreterState_Clear(tstate->interp);
/* Trigger a GC collection on subinterpreters*/
if (!is_main_interp) {
/* Last explicit GC collection */
_PyGC_CollectNoFail();
}
/* Clear all loghooks */
/* Both _PySys_Audit function and users still need PyObject, such as tuple.