[Python-bugs-list] Memory leak in Tkinter.py (PR#40)

peter.stoehr@weihenstephan.org peter.stoehr@weihenstephan.org
Fri, 30 Jul 1999 01:36:07 -0400 (EDT)


Full_Name: Peter Stoehr
Version: 1.5.2
OS: Linux
Submission from: ppp09.weihenstephan.org (194.95.200.169)


Hi Python-Fans,

Greg McFarlane (the developer of Pmw) and I found a memory leak in
Tkinter.py of Python 1.5.2.

The tag_bind method of the Canvas class maintainece a dict called
self._tagcommands to store lists of function-ids returned from the _bind
call.
As far as I can see, this information not used by any other method.
Furthermore, the lists grow with every call of tag_bind and the memory
is never released.

After removing the
        if sequence and func and res:
block of the tag_bind method, the memory consumption of the enclosed
test program is constant and no longer growing.

Is it okay to remove the 
        if sequence and func and res:
block or did I miss something?

    Greetings
        Peter

#########################################################################################

import Tkinter

def callback(event):
    pass

def autoUpdate():
    buttonId = canvas.bind('<ButtonPress>', callback)
    canvas.unbind('<ButtonPress>', buttonId)
    root.after(10, autoUpdate)

root = Tkinter.Tk()

canvas = Tkinter.Canvas(root)
idn = canvas.create_rectangle(100,100,200,200, fill='green')
canvas.pack()
autoUpdate()

root.mainloop()

##########################################################################################
-- 
---------------------------------------------------------------------------
   Dr. Peter Stoehr --- Teisenbergweg 6 --- 85435 Erding --- 08122/47232
---------------------------------------------------------------------------
                I'm the terror that flaps in the night