Объясните, пожалуйста, чего я неправильно делаю. Простейший пример:
Запускаю, после удаления линий память не освобождается.
#####################
from Tkinter import *
from Canvas import Line
import gc
class My(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
self.cv=Canvas(self, width=400, height=300)
self.cv.pack()
Button(self, command=self.cleanall, text="clean").pack(fill=X)
Button(self, command=self.addline, text="add").pack(fill=X)
self.pack()
self.x=10
self.y=10
self.l=[]
def addline(self):
for j in range(1000):
self.l.append(Line(self.cv, self.x, self.y, self.x+200, self.y, tag="line"))
self.y=self.y+20
def cleanall(self):
map(self.cv.delete, self.cv.find_withtag("line"))
self.x=10
self.y=10
for j in self.l:
del(j)
gc.collect()
root=Tk()
gc.enable()
a=My(root)
root.mainloop()
############################