Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-91632: Fix generic_alias_iterator to be finalized at exit.#91727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
corona10 merged 5 commits intopython:mainfromcorona10:gh-91632
Apr 20, 2022

Conversation

@corona10
Copy link
Member

@corona10corona10 commentedApr 20, 2022
edited
Loading

AS-IS

➜  cpython git:(main) ✗ cat gh-91632.pya = type(iter(tuple[int]))print(a.mro())➜  cpython git:(main) ✗ ./python.exe -X showrefcount gh-91632.py[<class 'generic_alias_iterator'>, <class 'object'>][119 refs, 46 blocks]

TO-BE

➜  cpython git:(gh-91632) ✗ cat gh-91632.pya = type(iter(tuple[int]))print(a.mro())➜  cpython git:(gh-91632) ✗ ./python.exe -X showrefcount gh-91632.py[<class 'generic_alias_iterator'>, <class 'object'>][0 refs, 0 blocks]

Follow Victor's suggestion :)

closes:#91632

@corona10corona10 changed the titleFix Py_GenericAliasIterType to be finalized at exit.gh-91632: Fix Py_GenericAliasIterType to be finalized at exit.Apr 20, 2022
@corona10corona10force-pushed thegh-91632 branch 2 times, most recently fromc7d5777 to39886d9CompareApril 20, 2022 05:53
@corona10corona10 changed the titlegh-91632: Fix Py_GenericAliasIterType to be finalized at exit.[WIP] gh-91632: Fix Py_GenericAliasIterType to be finalized at exit.Apr 20, 2022
@corona10corona10 changed the title[WIP] gh-91632: Fix Py_GenericAliasIterType to be finalized at exit.gh-91632: Fix Py_GenericAliasIterType to be finalized at exit.Apr 20, 2022
@corona10corona10 changed the titlegh-91632: Fix Py_GenericAliasIterType to be finalized at exit.gh-91632: Fix generic_alias_iterator to be finalized at exit.Apr 20, 2022
@Fidget-Spinner
Copy link
Member

I can't review this since I have no clue on the process of freeing memory on exit. But when do we add a type tostatic_types? Is it always?

@vstinner
Copy link
Member

I can't review this since I have no clue on the process of freeing memory on exit. But when do we add a type to static_types? Is it always?

I propose two approaches:

  • Convert static types to heap types to free memory at exit: it's a hard work, and currently hold by the SC. You need to wait untilhttps://peps.python.org/pep-0687/ is approved for that.

  • Clear static types at Python exit (usually in Py_Finalize()):

    • Add the type to the static_types list in object.c (I tried to add all types there),
    • or: add a "Fini" function called by finalize_interp_types() (be careful of sub-interpreters: see _Py_IsMainInterpreter() function).
Fidget-Spinner reacted with thumbs up emoji

corona10and others added2 commitsApril 20, 2022 21:44
…e-91632.cvUhsZ.rstCo-authored-by: Victor Stinner <vstinner@python.org>
@corona10corona10 requested a review fromvstinnerApril 20, 2022 12:52
Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM.

corona10 reacted with rocket emoji
@JelleZijlstra
Copy link
Member

Should this be backported?

@Fidget-Spinner
Copy link
Member

Fidget-Spinner commentedApr 20, 2022
edited
Loading

@JelleZijlstra No. Generic alias iterator is part of the variadic generics PEP which is 3.11 only iirc.

JelleZijlstra reacted with thumbs up emoji

@vstinner
Copy link
Member

Should this be backported?

The work to clear static types at exit is new in Python 3.11 (especially the _PyTypes_FiniTypes() function).

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@vstinnervstinnervstinner approved these changes

@gvanrossumgvanrossumAwaiting requested review from gvanrossum

@kumaraditya303kumaraditya303Awaiting requested review from kumaraditya303

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Memory leak with static iterator types

5 participants

@corona10@Fidget-Spinner@vstinner@JelleZijlstra@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp