bpo-1635741: Fix reference cycle by calling explicit gc collection in main interpreter by shihai1991 · Pull Request #21902 · python/cpython
shihai1991
changed the title
WIP: explict gc collection in main interpreter
bpo-1635741: explict gc collection in main interpreter
Before this PR:
sys.gettotalrefcount: 14288
sys.gettotalrefcount: 18042
sys.gettotalrefcount: 21796
sys.gettotalrefcount: 25550
sys.gettotalrefcount: 29304
sys.gettotalrefcount: 33058
sys.gettotalrefcount: 36812
sys.gettotalrefcount: 40566
sys.gettotalrefcount: 44320
sys.gettotalrefcount: 48074
After this PR:
sys.gettotalrefcount: 10537
sys.gettotalrefcount: 10540
sys.gettotalrefcount: 10543
sys.gettotalrefcount: 10546
sys.gettotalrefcount: 10549
sys.gettotalrefcount: 10552
sys.gettotalrefcount: 10555
sys.gettotalrefcount: 10558
sys.gettotalrefcount: 10561
sys.gettotalrefcount: 10564
shihai1991
changed the title
bpo-1635741: explict gc collection in main interpreter
bpo-1635741: Fix reference cycle by calling explicit gc collection in main interpreter
Merged since it seems to fix multiple issues: #21902 (comment)
Does it fix your issue with encoding names and encodings._aliases?
Merged since it seems to fix multiple issues: #21902 (comment)
Does it fix your issue with encoding names and encodings._aliases?
Yes, this PR have fix my issue. there have no remaining encodings.aliases in refdumps.
Thanks a million, victor. I have learned much in this issue.
I'm not sure that the GC is still fully functionnal after PyInterpreterState is cleared, but at least, it seems like there were a bunch of reference cycles.
cc @pablogsal
shihai1991 added a commit to shihai1991/cpython that referenced this pull request
…honGH-21902) Fix a reference cycle by triggering an explicit GC collection after calling PyInterpreterState_Clear().
Just curious, what are the three leaks.
You found this detail. I checked that some str object own the changed refcount in each iteration(not check the details).
xzy3 pushed a commit to xzy3/cpython that referenced this pull request
…honGH-21902) Fix a reference cycle by triggering an explicit GC collection after calling PyInterpreterState_Clear().
kylotan
mannequin
mentioned this pull request