Skip to content

[3.10] gh-94207: Fix struct module leak (GH-94239) - #94266

Merged
mdickinson merged 2 commits into
python:3.10from
miss-islington:backport-6b86534-3.10
Jun 25, 2022
Merged

mdickinson merged 2 commits into
python:3.10from
miss-islington:backport-6b86534-3.10

Conversation

@miss-islington

@miss-islington miss-islington commented Jun 25, 2022 •

Copy link
Copy Markdown
Contributor

Make _struct.Struct a GC type

This fixes a memory leak in the _struct module, where as soon
as a Struct object is stored in the cache, there's a cycle from
the _struct module to the cache to Struct objects to the Struct
type back to the module. If _struct.Struct is not gc-tracked, that
cycle is never collected.

This PR makes _struct.Struct GC-tracked, and adds a regression test.
(cherry picked from commit 6b86534)

Co-authored-by: Mark Dickinson mdickinson@enthought.com

Make _struct.Struct a GC type

This fixes a memory leak in the _struct module, where as soon
as a Struct object is stored in the cache, there's a cycle from
the _struct module to the cache to Struct objects to the Struct
type back to the module. If _struct.Struct is not gc-tracked, that
cycle is never collected.

This PR makes _struct.Struct GC-tracked, and adds a regression test.
(cherry picked from commit 6b86534)

Co-authored-by: Mark Dickinson <mdickinson@enthought.com>
@miss-islington

Copy link
Copy Markdown
Contributor Author

@mdickinson: Status check is done, and it's a success ❌ .

@mdickinson
mdickinson merged commit 86e49a5 into python:3.10 Jun 25, 2022
@miss-islington
miss-islington deleted the backport-6b86534-3.10 branch June 25, 2022 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants