[ python-Bugs-781883 ] Listbox itemconfigure leaks memory

SourceForge.net noreply at sourceforge.net
Tue Jun 15 23:10:16 EDT 2004


Bugs item #781883, was opened at 2003-08-02 04:01
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=781883&group_id=5470

Category: Tkinter
>Group: 3rd Party
>Status: Closed
>Resolution: Rejected
Priority: 5
Submitted By: Angelo Bonet (abonet)
>Assigned to: Neal Norwitz (nnorwitz)
Summary: Listbox itemconfigure leaks memory

Initial Comment:
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()


----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2004-06-15 23:10

Message:
Logged In: YES 
user_id=33168

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

----------------------------------------------------------------------

Comment By: Jeff Epler (jepler)
Date: 2003-08-03 11:24

Message:
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


----------------------------------------------------------------------

Comment By: Angelo Bonet (abonet)
Date: 2003-08-02 16:40

Message:
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.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2003-08-02 05:01

Message:
Logged In: YES 
user_id=80475

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

----------------------------------------------------------------------

Comment By: Angelo Bonet (abonet)
Date: 2003-08-02 04:06

Message:
Logged In: YES 
user_id=716439

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

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=781883&group_id=5470



More information about the Python-bugs-list mailing list