[matplotlib-devel] GC support
Travis and others, In the course of trying to understand memory leaks in matplotlib I have been trying to understand a bit about the garbage collector. If I understand correctly, any container that can can hold references to other containers could lead to a reference cycle; if the container supports the gc mechanism, then the gc can at least find the cycles. If the containers do not have __del__ methods, then the gc can also break the cycles and reclaim the memory. (This also seems to imply that __del__ methods should be avoided if at all possible, and I don't understand the implications and applications of this.) I notice that numpy.ndarray does not support the gc, correct? And since an ndarray can hold other containers, it could lead to uncollectable cycles, correct? Did you decide not to include gc support because it is not actually needed or useful? If so, what am I missing? I don't think the lack of gc support in numpy has anything to do with the present leak problem in mpl, so I am asking about numpy partly out of curiosity, and partly in the hope that your answer will help me understand exactly when one really needs to worry about gc support in extension code--mpl has quite a bit of extension code, and relies on much outside extension code as well. The one little bit of extension code I wrote for numpy, the wrapper part of the contour routine, does not support the gc--and if this is a mistake, I want to know about it. (I am beginning to suspect that it should support the gc, although it is not part of our most basic problem at the moment.) Googling has not turned up much information beyond the standard python docs about the gc, extension code, and memory leaks in python. Thanks for whatever insight and advice you can provide. Eric - 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-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
[matplotlib-devel] Qt4 bug on OSX with close()
Hi all, I'm wondering if anyone knows what the problem is (traceback at the end). If I use close() when running with the Qt4Agg backend under OSX, the figures do not close, and I get a nasty traceback instead. Perhaps the problem also exists on other OSes (I hope, so it's easier to fix), but I only have a Qt4 build on OSX (PPC) 10.4.9. This is with a fairly recent SVN build: In [21]: matplotlib.__revision__ Out[21]: '$Revision: 3125 $' Any help on this one would be greatly appreciated (and John: I think this is the backend we'll be using, so it would be very nice to get this fixed :) Cheers, f In [19]: close('all') --- Traceback (most recent call last) /Users/fperez/py4science/examples/ in () /usr/local/txpython/local/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/pylab.py in close(*args) 728 if arg=='all': 729 for manager in _pylab_helpers.Gcf.get_all_fig_managers(): --> 730 _pylab_helpers.Gcf.destroy(manager.num) 731 elif isinstance(arg, int): 732 _pylab_helpers.Gcf.destroy(arg) /usr/local/txpython/local/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/_pylab_helpers.py in destroy(num) 26 del Gcf.figs[num] 27 #print len(Gcf.figs.keys()), len(Gcf._activeQue) ---> 28 figManager.destroy() 29 gc.collect() 30 /usr/local/txpython/local/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/matplotlib/backends/backend_qt4.py in destroy(self, *args) 246 self.window._destroying = True 247 if DEBUG: print "destroy figure manager" --> 248 self.window.close(True) 249 250 class NavigationToolbar2QT( NavigationToolbar2, QtGui.QWidget ): : too many arguments to QWidget.close(), 0 at most expected - 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-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel