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 |