Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from Nov 24, 2023

Conversation

hperrey
Copy link
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
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.

IPython/terminal/pt_inputhooks/qt.py Outdated Show resolved Hide resolved
@ccordoba12 ccordoba12 added this to the 8.18 milestone Nov 24, 2023
Co-authored-by: Carlos Cordoba <ccordoba12@gmail.com>
@Carreau
Copy link
Member

Carreau commented Nov 24, 2023

Thanks for the PR and the review !

@Carreau Carreau merged commit c0a699d into ipython:main Nov 24, 2023
21 checks passed
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