SourceForge logo
SourceForge logo
Menu

matplotlib-devel — matplotlib developers

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
(1)
Nov
(33)
Dec
(20)
2004 Jan
(7)
Feb
(44)
Mar
(51)
Apr
(43)
May
(43)
Jun
(36)
Jul
(61)
Aug
(44)
Sep
(25)
Oct
(82)
Nov
(97)
Dec
(47)
2005 Jan
(77)
Feb
(143)
Mar
(42)
Apr
(31)
May
(93)
Jun
(93)
Jul
(35)
Aug
(78)
Sep
(56)
Oct
(44)
Nov
(72)
Dec
(75)
2006 Jan
(116)
Feb
(99)
Mar
(181)
Apr
(171)
May
(112)
Jun
(86)
Jul
(91)
Aug
(111)
Sep
(77)
Oct
(72)
Nov
(57)
Dec
(51)
2007 Jan
(64)
Feb
(116)
Mar
(70)
Apr
(74)
May
(53)
Jun
(40)
Jul
(519)
Aug
(151)
Sep
(132)
Oct
(74)
Nov
(282)
Dec
(190)
2008 Jan
(141)
Feb
(67)
Mar
(69)
Apr
(96)
May
(227)
Jun
(404)
Jul
(399)
Aug
(96)
Sep
(120)
Oct
(205)
Nov
(126)
Dec
(261)
2009 Jan
(136)
Feb
(136)
Mar
(119)
Apr
(124)
May
(155)
Jun
(98)
Jul
(136)
Aug
(292)
Sep
(174)
Oct
(126)
Nov
(126)
Dec
(79)
2010 Jan
(109)
Feb
(83)
Mar
(139)
Apr
(91)
May
(79)
Jun
(164)
Jul
(184)
Aug
(146)
Sep
(163)
Oct
(128)
Nov
(70)
Dec
(73)
2011 Jan
(235)
Feb
(165)
Mar
(147)
Apr
(86)
May
(74)
Jun
(118)
Jul
(65)
Aug
(75)
Sep
(162)
Oct
(94)
Nov
(48)
Dec
(44)
2012 Jan
(49)
Feb
(40)
Mar
(88)
Apr
(35)
May
(52)
Jun
(69)
Jul
(90)
Aug
(123)
Sep
(112)
Oct
(120)
Nov
(105)
Dec
(116)
2013 Jan
(76)
Feb
(26)
Mar
(78)
Apr
(43)
May
(61)
Jun
(53)
Jul
(147)
Aug
(85)
Sep
(83)
Oct
(122)
Nov
(18)
Dec
(27)
2014 Jan
(58)
Feb
(25)
Mar
(49)
Apr
(17)
May
(29)
Jun
(39)
Jul
(53)
Aug
(52)
Sep
(35)
Oct
(47)
Nov
(110)
Dec
(27)
2015 Jan
(50)
Feb
(93)
Mar
(96)
Apr
(30)
May
(55)
Jun
(83)
Jul
(44)
Aug
(8)
Sep
(5)
Oct
Nov
(1)
Dec
(1)
2016 Jan
Feb
Mar
(1)
Apr
May
Jun
(2)
Jul
Aug
(3)
Sep
(1)
Oct
(3)
Nov
Dec
2017 Jan
Feb
(5)
Mar
Apr
May
Jun
Jul
(3)
Aug
Sep
(7)
Oct
Nov
Dec
2018 Jan
Feb
Mar
Apr
May
Jun
Jul
(2)
Aug
Sep
Oct
Nov
Dec
S M T W T F S





1
(3)
2
(4)
3
4
(1)
5
6
7
(2)
8
9
(2)
10
11
12
13
(1)
14
(3)
15
16
17
18
(1)
19
(1)
20
(5)
21
(2)
22
23
24
25
(2)
26
(1)
27
(3)
28
(1)
29
(1)
30
(7)

Showing 1 results of 1

From: Michael D. <md...@st...> - 2007年06月29日 17:48:16
Attachments: cycle_finder.py
I've been looking into the memory leaks exercised by the memleak_gui.py 
unit test. I've searched through the mailing list for information, but 
I'm new to the party here, so forgive me if I'm not fully current.
Eric Firing wrote:
"I think we have a similar problem with all interactive backends (the 
only one I didn't test is Qt4Agg) which also makes me suspect we are 
violating some gui rule, rather than that gtk, qt3, wx, and tk all have 
leaks."
Unfortunately, from what I've seen, there isn't a single rule being 
broken, but instead I've been running into lots of different "surprises" 
in the various toolkits. But I am starting to suspect that my old 
versions of Gtk (or PyGtk) have some bonafide leaks.
I just finished submitting patches (to the tracker) for a number of 
memory leaks in the Tk, Gtk, and Wx backends (other backends will 
hopefully follow). I did all my testing on RHEL4 with Python 2.5 and 
recent SVN matplotlib (rev. 3244), so it's quite possible that memory 
leaks still remain on other platforms.
Tk:
See the patch:
http://sourceforge.net/tracker/index.php?func=detail&aid=1745400&group_id=80706&atid=560722
Even after this patch, Tkinter still leaks 28 bytes every time it is 
initialized (every time a toplevel window is created). There may be a 
way to avoid the subsequent initializations, but it wasn't immediately 
obvious to me, and given the small size of this leak, I've passed on it 
for now.
Gtk:
See the patch:
http://sourceforge.net/tracker/index.php?func=detail&aid=1745406&group_id=80706&atid=560722
The patch fixes a number of Python-level leaks.
Unfortunately, the Gdk rendering backend still leaks gtk.gdk.Window 
objects, and I have so far been unable to determine a fix. GtkAgg, 
however, does not have this leak.
Under pygtk-2.4.0, the toolbars leak gdk.Pixbuf's and file selector dialogs.
Since these issues appear to be bugs in gtk and/or pygtk itself, I will 
probably first try a more recent version of them. (The gtk installed on 
RHEL4 is ancient (2.4), and I haven't yet tried building my own. If 
anyone has a more recent version of pygtk handy, I would appreciate a 
report from memleak_gui.py after applying my patch.)
Wx:
See the patch:
http://sourceforge.net/tracker/index.php?func=detail&aid=1745408&group_id=80706&atid=560722
This one was fairly simple, though surprising. Top-level windows do not 
fully destroy themselves as long as there are pending events. Manually 
flushing the event queue causes the windows to go away. See the 
wxPython docs:
http://wxwidgets.org/manuals/stable/wx_wxwindow.html#wxwindowdestroy
There were no further leaks in Wx/WxAgg that I was able to detect (in my 
environment).
As an aside, I thought I'd share the techniques I used to find these 
leaks (hopefully not to be pedantic, but these things were hard to come 
by online...), and it might be useful to some.
For C/C++ memory leaks, I really like valgrind (though it is 
Linux-only), though be sure to follow the directions to get it to play 
well with Python. I recommend rebuilding Python with 
"--without-pymalloc" to make memory reporting in general much more 
sensical (though slower). See:
 http://svn.python.org/view/python/trunk/Misc/README.valgrind
For an example, you can see the rsvg memory leak here:
==15979== 1,280 bytes in 20 blocks are definitely lost in loss record 
13,506 of 13,885
==15979== at 0x4004405: malloc (vg_replace_malloc.c:149)
==15979== by 0x314941: (within /usr/lib/libart_lgpl_2.so.2.3.16)
==15979== by 0x315E0C: (within /usr/lib/libart_lgpl_2.so.2.3.16)
==15979== by 0x31624A: art_svp_intersector (in 
/usr/lib/libart_lgpl_2.so.2.3.16)
==15979== by 0x316660: art_svp_intersect (in 
/usr/lib/libart_lgpl_2.so.2.3.16)
==15979== by 0x6BFA86C: (within /usr/lib/librsvg-2.so.2.8.1)
==15979== by 0x6BFD801: rsvg_render_path (in /usr/lib/librsvg-2.so.2.8.1)
==15979== by 0x6BFD9E7: rsvg_handle_path (in /usr/lib/librsvg-2.so.2.8.1)
==15979== by 0x6BFFDB5: rsvg_start_path (in /usr/lib/librsvg-2.so.2.8.1)
==15979== by 0x6C07F59: (within /usr/lib/librsvg-2.so.2.8.1)
==15979== by 0x9C24BB: xmlParseStartTag (in /usr/lib/libxml2.so.2.6.16)
==15979== by 0xA4DADC: xmlParseChunk (in /usr/lib/libxml2.so.2.6.16)
==15979== by 0x6C08ED5: rsvg_handle_write_impl (in 
/usr/lib/librsvg-2.so.2.8.1)
==15979== by 0x6C09539: rsvg_handle_write (in 
/usr/lib/librsvg-2.so.2.8.1)
==15979== by 0x5D51B51: (within 
/usr/lib/gtk-2.0/2.4.0/loaders/svg_loader.so)
==15979== by 0x32871F: (within /usr/lib/libgdk_pixbuf-2.0.so.0.400.13)
==15979== by 0x32885E: gdk_pixbuf_new_from_file (in 
/usr/lib/libgdk_pixbuf-2.0.so.0.400.13)
==15979== by 0x5CEE34: (within /usr/lib/libgtk-x11-2.0.so.0.400.13)
==15979== by 0x5CF095: gtk_window_set_default_icon_from_file (in 
/usr/lib/libgtk-x11-2.0.so.0.400.13)
==15979== by 0x59FCD1B: _wrap_gtk_window_set_default_icon_from_file 
(gtk.c:38156)
==15979== by 0x80C29B6: PyEval_EvalFrameEx (ceval.c:3564)
For finding cycles that result in uncollectable garbage, I wrote a 
cycle-finding utility (see attached file). (I plan to submit this as a 
Python Cookbook entry). Given a list of objects of interest, it will 
print out all the reference cycles involving those objects (though it 
can't traverse through extension objects that don't expose reference 
information to the garbage collector).
Objects that leak because legitimate Python references to them are still 
around are some of the trickiest to find. (This was an answer to a job 
interview question I was once asked: "How can you leak memory in 
Java/some other garbage collected language?") I find it useful to 
compare snapshots of all the objects in the interpreter before and after 
a suspected leak:
 existing_objects = [id(x) for x in gc.get_objects()]
 # ... do something that leaks ...
 # ... delete everything you can ...
 remaining_objects = [x for x in gc.get_objects() if id(x) not in 
existing_objects]
One can then scour through remaining_objects for anything that suspected 
of causing the problem, and do cycle detection on those objects, if 
necessary to find ways to forcibly remove them.
Cheers,
Mike

Showing 1 results of 1

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /