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

Listbox itemconfigure leaks memory #38998

Closed
abonet mannequin opened this issue Aug 2, 2003 · 6 comments
Closed

Listbox itemconfigure leaks memory #38998

abonet mannequin opened this issue Aug 2, 2003 · 6 comments

Comments

@abonet
Copy link
Mannequin

abonet mannequin commented Aug 2, 2003

BPO 781883
Nosy @rhettinger
Files
  • itemcfg.py: Demonstration script
  • 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 2004-06-16.03:10:16.000>
    created_at = <Date 2003-08-02.08:01:30.000>
    labels = ['expert-tkinter']
    title = 'Listbox itemconfigure leaks memory'
    updated_at = <Date 2004-06-16.03:10:16.000>
    user = 'https://bugs.python.org/abonet'

    bugs.python.org fields:

    activity = <Date 2004-06-16.03:10:16.000>
    actor = 'nnorwitz'
    assignee = 'nnorwitz'
    closed = True
    closed_date = None
    closer = None
    components = ['Tkinter']
    creation = <Date 2003-08-02.08:01:30.000>
    creator = 'abonet'
    dependencies = []
    files = ['992']
    hgrepos = []
    issue_num = 781883
    keywords = []
    message_count = 6.0
    messages = ['17575', '17576', '17577', '17578', '17579', '17580']
    nosy_count = 4.0
    nosy_names = ['nnorwitz', 'jepler', 'rhettinger', 'abonet']
    pr_nums = []
    priority = 'normal'
    resolution = 'rejected'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue781883'
    versions = []

    @abonet
    Copy link
    Mannequin Author

    abonet mannequin commented Aug 2, 2003

    Calling itemconfigure on Tkinter.Listbox to change item
    colors seems to leak memory without bounds. I've seen
    this in Python 2.2 and 2.3 on SunOS, Tru64, and Linux.

    Here's a small script that demostrates it:

    import Tkinter as Tk
    Lb = None
    
    def update_lb ():
        global Lb    
        Lb.delete(0, Tk.END)
    
        for ii in range(100):
            Lb.insert(Tk.END, 'Item %d' % ii)
            Lb.itemconfigure(ii, bg='red')
    
        Lb.after(10, update_lb)
    
    
    root = Tk.Tk()
    Lb = Tk.Listbox(root)
    Lb.pack()
    Lb.after(1000, update_lb)
    root.mainloop()

    @abonet abonet mannequin closed this as completed Aug 2, 2003
    @abonet abonet mannequin assigned nnorwitz Aug 2, 2003
    @abonet abonet mannequin added the topic-tkinter label Aug 2, 2003
    @abonet abonet mannequin closed this as completed Aug 2, 2003
    @abonet abonet mannequin assigned nnorwitz Aug 2, 2003
    @abonet abonet mannequin added the topic-tkinter label Aug 2, 2003
    @abonet
    Copy link
    Mannequin Author

    abonet mannequin commented Aug 2, 2003

    Logged In: YES
    user_id=716439

    Sorry, but indentation got lost on script sample. Look at
    attached file instead.

    @rhettinger
    Copy link
    Contributor

    Logged In: YES
    user_id=80475

    Try a gc.collect() to see if the problem persists.

    @abonet
    Copy link
    Mannequin Author

    abonet mannequin commented Aug 2, 2003

    Logged In: YES
    user_id=716439

    Calling gc.collect() seems to reduce the rate at which
    memory is leaking, but it does not eliminate the leak.

    @jepler
    Copy link
    Mannequin

    jepler mannequin commented Aug 3, 2003

    Logged In: YES
    user_id=2772

    The problem can be seen in an equivalent tcl script. This may indicate that the problem is not in Python itself, but in the third-party Tcl/Tk library.

    The script follows. I hope indentation isn't lost, but at least Tk has curly braces for just such an emergency.

    proc update_lb {} {
    .lb delete 0 end
    for {set i 0} {$i < 100} {incr i} {
    .lb insert end "Item $i"
    .lb itemco $i -bg red
    }
    after 10 update_lb
    }

    listbox .lb
    pack .lb
    after 10 update_lb

    @nnorwitz
    Copy link
    Mannequin

    nnorwitz mannequin commented Jun 16, 2004

    Logged In: YES
    user_id=33168

    Closing this since it seems to be related to Tcl/Tk, not Python.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant