Skip to content

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

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

Fix memory leak in Qt event loop integration (#14240)#14251
Carreau merged 2 commits intoipython:mainfrom
hperrey:fix_14240

Conversation

@hperrey
Copy link
Copy Markdown
Contributor

@hperrey hperrey commented Nov 23, 2023

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
Copy link
Copy Markdown
Member

@ccordoba12 ccordoba12 left a comment

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.

@ccordoba12 ccordoba12 added this to the 8.18 milestone Nov 24, 2023
Co-authored-by: Carlos Cordoba <ccordoba12@gmail.com>
@Carreau
Copy link
Copy Markdown
Member

Carreau commented Nov 24, 2023

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