Skip to content

Fix memory leak in Qt event loop integration (#14240) - #14251

Merged
Carreau merged 2 commits into
ipython:mainfrom
hperrey:fix_14240
Nov 24, 2023
Merged

Carreau merged 2 commits into
ipython:mainfrom
hperrey:fix_14240

Conversation

@hperrey

@hperrey hperrey commented Nov 23, 2023

Copy link
Copy Markdown
Contributor

The QEventLoop object, event_loop, created in IPython/terminal/pt_intputhooks/qt.py L58 is not deleted when exiting the scope as passing app to the constructor parents the object to app. This creates a memory leak as QEventLoop objects are being accumulated.

The issue was originally reported by @pag who also suggested the fix.

pytest IPython/terminal/tests/ runs through without errors. I have tested the changes and see no more accumulation of QEventLoop objects.

This fixes #14240

See: ipython#14240

- the QEventLoop, `event_loop`, is not deleted when exiting the scope as
passing `app` to the constructor parents the object to `app`. This
creates a memory leak as QEventLoop objects are being accumulated.
- issue reported by and fix suggested by @pag

@ccordoba12 ccordoba12 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@hperrey, a small suggestion for you, then it should be good to be merged.

Comment thread IPython/terminal/pt_inputhooks/qt.py Outdated
@ccordoba12 ccordoba12 added this to the 8.18 milestone Nov 24, 2023
@Carreau

Carreau commented Nov 24, 2023

Copy link
Copy Markdown
Member

Thanks for the PR and the review !

@Carreau
Carreau merged commit c0a699d into ipython:main Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory leak with %matplotlib qt, with simple fix

3 participants