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

Memory leak in Tkinter #78975

Closed
dtalkin mannequin opened this issue Sep 24, 2018 · 8 comments
Closed

Memory leak in Tkinter #78975

dtalkin mannequin opened this issue Sep 24, 2018 · 8 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes performance Performance or resource usage topic-tkinter

Comments

@dtalkin
Copy link
Mannequin

dtalkin mannequin commented Sep 24, 2018

BPO 34794
Nosy @vstinner, @serhiy-storchaka, @miss-islington, @tirkarthi
PRs
  • [2.7] bpo-34794: Fix a memory leak in Tkinter.Image. #9559
  • bpo-34794: Fix a leak in Tkinter. #10025
  • [3.7] bpo-34794: Fix a leak in Tkinter. (GH-10025) #10069
  • [3.6] bpo-34794: Fix a leak in Tkinter. (GH-10025) #10070
  • [2.7] bpo-34794: Fix a leak in Tkinter. (GH-10025) #10181
  • Files
  • leak_demo.py
  • leak_demo2.py
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2018-10-28.19:14:46.622>
    created_at = <Date 2018-09-24.21:30:12.174>
    labels = ['3.8', '3.7', 'expert-tkinter', 'performance']
    title = 'Memory leak in Tkinter'
    updated_at = <Date 2018-10-28.19:14:46.621>
    user = 'https://bugs.python.org/dtalkin'

    bugs.python.org fields:

    activity = <Date 2018-10-28.19:14:46.621>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-10-28.19:14:46.622>
    closer = 'serhiy.storchaka'
    components = ['Tkinter']
    creation = <Date 2018-09-24.21:30:12.174>
    creator = 'dtalkin'
    dependencies = []
    files = ['47821', '47886']
    hgrepos = []
    issue_num = 34794
    keywords = ['patch']
    message_count = 8.0
    messages = ['326289', '326327', '326355', '328205', '328338', '328342', '328347', '328715']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'serhiy.storchaka', 'miss-islington', 'xtreak', 'dtalkin']
    pr_nums = ['9559', '10025', '10069', '10070', '10181']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'resource usage'
    url = 'https://bugs.python.org/issue34794'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7', 'Python 3.8']

    @dtalkin
    Copy link
    Mannequin Author

    dtalkin mannequin commented Sep 24, 2018

    The Tkinter.PhotoImage class leaks memory with each change of the 'data' Attribute due to Image calling tk._createbytearray, which allocates memory, but never frees it.

    The offending method is in the TkApp class, _createbytearray().

    @dtalkin dtalkin mannequin added topic-tkinter performance Performance or resource usage labels Sep 24, 2018
    @tirkarthi
    Copy link
    Member

    Thanks for the report David. Feel free to attach reproducible script if any that might trigger this. I am adding Serhiy who might have a better understanding of this. Relevant issue where _createbytearray was added : bpo-21580 .

    @dtalkin
    Copy link
    Mannequin Author

    dtalkin mannequin commented Sep 25, 2018

    Attached please find a Python script that demonstrates the bug.

    David

    On Tue, Sep 25, 2018 at 2:55 AM Karthikeyan Singaravelan <
    report@bugs.python.org> wrote:

    Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment:

    Thanks for the report David. Feel free to attach reproducible script if
    any that might trigger this. I am adding Serhiy who might have a better
    understanding of this. Relevant issue where _createbytearray was added :
    bpo-21580 .

    ----------
    nosy: +serhiy.storchaka, xtreak


    Python tracker <report@bugs.python.org>
    <https://bugs.python.org/issue34794\>


    @serhiy-storchaka
    Copy link
    Member

    Here is a simpler reproducer.

    Actually the problem was not in _createbytearray(), but in converting the Python wrapper around Tcl_Obj into Tcl_Obj. _createbytearray() just exposed it. The leak exists in Python 3 too, but it is hard to reproduce it.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life 3.8 only security fixes labels Oct 21, 2018
    @serhiy-storchaka serhiy-storchaka changed the title memory leak in TkApp:_createbytearray Memory leak in Tkinter Oct 21, 2018
    @serhiy-storchaka
    Copy link
    Member

    New changeset df13df4 by Serhiy Storchaka in branch 'master':
    bpo-34794: Fix a leak in Tkinter. (GH-10025)
    df13df4

    @miss-islington
    Copy link
    Contributor

    New changeset 2c54925 by Miss Islington (bot) in branch '3.6':
    bpo-34794: Fix a leak in Tkinter. (GH-10025)
    2c54925

    @vstinner
    Copy link
    Member

    New changeset f7cefb4 by Victor Stinner (Miss Islington (bot)) in branch '3.7':
    bpo-34794: Fix a leak in Tkinter. (GH-10025) (GH-10069)
    f7cefb4

    @serhiy-storchaka
    Copy link
    Member

    New changeset aaea280 by Serhiy Storchaka in branch '2.7':
    [2.7] bpo-34794: Fix a leak in Tkinter. (GH-10025) (GH-10181)
    aaea280

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes performance Performance or resource usage topic-tkinter
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants