Skip to content

[3.11] gh-94207: Fix struct module leak (GH-94239) - #94265

Merged
mdickinson merged 1 commit into
python:3.11from
miss-islington:backport-6b86534-3.11
Jun 25, 2022
Merged

mdickinson merged 1 commit into
python:3.11from
miss-islington:backport-6b86534-3.11

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

Status check is done, and it's a success ✅ .

@miss-islington

Copy link
Copy Markdown
Contributor Author

Status check is done, and it's a success ✅ .

@mdickinson
mdickinson merged commit 4bc5f9f into python:3.11 Jun 25, 2022
@miss-islington
miss-islington deleted the backport-6b86534-3.11 branch June 25, 2022 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants