Объясните, пожалуйста, чего я неправильно делаю. Простейший пример:
Запускаю, после удаления линий память не освобождается.
1 from Tkinter import *
2 from Canvas import Line
3 import gc
4
5 class My(Frame):
6 def __init__(self, parent):
7 Frame.__init__(self, parent)
8 self.cv=Canvas(self, width=400, height=300)
9 self.cv.pack()
10 Button(self, command=self.cleanall, text="clean").pack(fill=X)
11 Button(self, command=self.addline, text="add").pack(fill=X)
12 self.pack()
13 self.x=10
14 self.y=10
15 self.l=[]
16
17 def addline(self):
18 for j in range(1000):
19 self.l.append(Line(self.cv, self.x, self.y, self.x+200, self.y, tag="line"))
20 self.y=self.y+20
21
22 def cleanall(self):
23 map(self.cv.delete, self.cv.find_withtag("line"))
24 self.x=10
25 self.y=10
26 for j in self.l:
27 del(j)
28 gc.collect()
29
30 root=Tk()
31 gc.enable()
32 a=My(root)
33 root.mainloop()
############################