GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-1635741: Fix reference cycle by calling explicit gc collection in main interpreter by shihai1991 · Pull Request #21902 · python/cpython

Conversation

@shihai1991

@shihai1991 shihai1991 commented Aug 17, 2020 •
edited by bedevere-bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Authored-by: Victor Stinner [email protected]

https://bugs.python.org/issue1635741

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@shihai1991
explict gc collect in main interpreter
e9afe6f
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Aug 17, 2020
@bedevere-bot bedevere-bot added the awaiting review label Aug 17, 2020
@shihai1991 shihai1991 mentioned this pull request Aug 17, 2020
bpo-1635741: Fix refleaks of encodings module by removing the encodings._aliases #21896
Closed
@shihai1991 shihai1991 changed the title WIP: explict gc collection in main interpreter bpo-1635741: explict gc collection in main interpreter Aug 17, 2020
@shihai1991

shihai1991 commented Aug 17, 2020

Copy link
Copy Markdown
Member Author

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@shihai1991 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 Aug 17, 2020
@vstinner vstinner added the skip news label Aug 17, 2020
@vstinner
vstinner merged commit 8aa163e into python:master Aug 17, 2020
@bedevere-bot bedevere-bot removed the awaiting review label Aug 17, 2020
@vstinner

vstinner commented Aug 17, 2020

Copy link
Copy Markdown
Member

Merged since it seems to fix multiple issues: #21902 (comment)

Does it fix your issue with encoding names and encodings._aliases?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Aug 17, 2020

Copy link
Copy Markdown
Member

cc @ncoghlan @ericsnowcurrently: Python finalization is getting better ;-) Yet another GC collection at exit!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@shihai1991

shihai1991 commented Aug 17, 2020

Copy link
Copy Markdown
Member Author

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Aug 18, 2020

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

shihai1991 added a commit to shihai1991/cpython that referenced this pull request Aug 20, 2020
@shihai1991
bpo-1635741: Explict GC collect after PyInterpreterState_Clear() (pyt…
2ee8174
…honGH-21902)

Fix a reference cycle by triggering an explicit GC collection
after calling PyInterpreterState_Clear().
@ghost

ghost commented Aug 26, 2020

Copy link
Copy Markdown

Just curious, what are the three leaks.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@shihai1991

shihai1991 commented Aug 26, 2020

Copy link
Copy Markdown
Member Author

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).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

xzy3 pushed a commit to xzy3/cpython that referenced this pull request Oct 18, 2020
@shihai1991 @xzy3-cdc
bpo-1635741: Explict GC collect after PyInterpreterState_Clear() (pyt…
4d20475
…honGH-21902)

Fix a reference cycle by triggering an explicit GC collection
after calling PyInterpreterState_Clear().
@kylotan kylotan mannequin mentioned this pull request Sep 19, 2022
Py_Finalize() doesn't clear all Python objects at exit #44470
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@shihai1991 @vstinner @the-knights-who-say-ni @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.