SourceForge logo
SourceForge logo
Menu

[matplotlib-devel] vanishing memory leaks

From: John H. <jdh...@ac...> - 2004年07月22日 14:41:33
Last night hayden (jo...@on...) sent me a patch in which he
identified and fixed two leaks in _backend_agg.cpp, one in the
write_png method and one elsewhere. Spurred on by his successes, I
tracked down and fixed some additional leaks in the _transforms and
ft2font modules.
Using units/memleak_hawaii3.py in CVS for test script, on typical runs
creating hundreds of random, complex figures, I get anywhere from -5
up to 40 bytes per figure. Since this range is sometimes negative, it
may reflect statistical fluctuation. This number is down from 400
bytes per figure in 0.60.2 (and 24K in 0.54.2) and is getting into the
"manageably small" range. Of course, there is always the possibility
of a leak in an untested area, but I'm encouraged....
Lessons for developers (and me):
 * in pycxx extension code, you almost always want to return
 Py::asObject rather than Py::Object. One exception is returning
 None as Py::Object(). This caused several leaks in the ft2font
 module.
 * Never incref where you meant to decref! This was the cause of the
 leak in the _transforms module, which had escaped my earlier unit
 tests because I wasn't unit testing the leak of binary operations
 of lazy values. In the BinOp class, I was incref-ing in the
 destructor. Very bad...
 * Use freetype 2.1.9 since this fixes some leaks in earlier
 versions.
JDH

View entire thread

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 によって変換されたページ (->オリジナル) /