Eric, Not much progress, I think. Memory leaks seem endemic to the gui backends, although Tk is by far the worst. I have been trying to understand the gtk case in the hope of discovering some simple change in mpl code that might eliminate the problem there and turn out to be applicable to the other backends as well. But I have not found the source of the problem, and it seems to occur even in a very simple test gui script using pure pygtk, with no mpl. I need to do more testing to find out whether the gtk problem is specific to use of gtk.Toolbar, or whether it will occur with any nested widgets. It seems that widgets are not getting destroyed completely; maybe there are some references lurking somewhere in the dark. With gtk, the garbage collector does not find any cycles that it can't deal with, but if I remember correctly from earlier testing, this is not the case with Tk.
As a partial workaround, if you don't need the toolbar, try setting rcParams['toolbar'] = None This may make the leak much smaller. I think the toolbar causes problems in all guis simply because it increases the complexity and number of widgets being tracked, if for no other reason. I would be delighted if a gui guru would emerge with a thorough explanation and solution for the memory leaks occurring with repeated opening and closing of windows. Eric Pellegrini Eric wrote: > Hi evebrybody, > > I started a discussion one week ago about a problem of memory leak using > the following code: > > ******************************************************************************** > from Tkinter import * > from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg > import pylab > > def display(): > mat = pylab.zeros((100,100)) > pylab.ioff() > image = pylab.matshow(mat) > pylab.ion() > pylab.close() > can = FigureCanvasTkAgg(image, master=frame) > can.show() > can.get_tk_widget().grid(row = 0,column = 0) > > root = Tk() > frame = Frame(root) > frame.grid(row = 0,column = 0) > canvas = Canvas(frame, width = 240, height = 240, relief = "sunken", bg > = "white") > canvas.grid() > button = Button(root,text="DisplayMatrix",command = display) > button.grid(row = 1,column = 0) > ******************************************************************************* > > up to now, I have not found any way to solve it and unfortunately the > proposed hints did not solve the problem (gc_collect(), clf(), cla()). > Is there something new about this ? > > thanks > > Eric > > ------------------------------------------------------------------------ > Découvrez une nouvelle façon d'obtenir des réponses à toutes vos > questions ! Profitez des connaissances, des opinions et des expériences > des internautes sur Yahoo! Questions/Réponses > <http://fr.rd.yahoo.com/evt=42054/*http://fr.answers.yahoo.com>. > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > > ------------------------------------------------------------------------ > > _______________________________________________ > Matplotlib-users mailing list > Matplotlib-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/matplotlib-users ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users