Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e9c86d4

Browse files
committed
more memory leak fixes
svn path=/trunk/matplotlib/; revision=423
1 parent e11f0f9 commit e9c86d4

4 files changed

Lines changed: 23 additions & 15 deletions

File tree

CHANGELOG

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
New entries should be added at the top
22

3-
2004-07-21 Applied backend_agg memory leak patch from hayden
4-
- [email protected]. Found and fixed a leak in binary
5-
operations on transforms. Moral of the story: never incref
6-
where you meant to decref!- JDH
3+
2004-07-21 Applied backend_agg memory leak patch from hayden -
4+
[email protected]. Found and fixed a leak in binary
5+
operations on transforms. Moral of the story: never
6+
incref where you meant to decref! Fixed several leaks in
7+
ft2font: moral of story: almost always return Py::asObject
8+
over Py::Object - JDH
79

810
2004-07-21 Fixed a to string memory allocation bug in agg and image
911
modules - JDH

TODO

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@
428428

429429
-- DONE fix set_def font example and update API_CHANGES
430430

431-
-- upload 0.54.2 zip
431+
-- CLOSED upload 0.54.2 zip
432432

433433
-- DONE need a new way to indicate linestyle
434434

@@ -471,7 +471,7 @@
471471

472472
-- DONE update nav section of tutorial
473473

474-
-- track down transforms memleak
474+
-- DONE track down transforms memleak
475475

476476
-- DONE make sure you handle cacheing of rotated mathtext properly
477477

@@ -481,4 +481,6 @@
481481

482482
-- add new connect to API_CHANGES
483483

484-
--port new toolbar to embedding examples
484+
-- port new toolbar to embedding examples
485+
486+
-- \sum height problem - see mathtext_tut

src/ft2font.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ FT2Font::image_as_str(const Py::Tuple & args) {
597597
_VERBOSE("FT2Font::image_as_str");
598598
args.verify_length(0);
599599

600-
return Py::Object(
600+
return Py::asObject(
601601
Py_BuildValue("lls#",
602602
image.width,
603603
image.height,
@@ -850,8 +850,8 @@ FT2Font::get_name_index(const Py::Tuple & args) {
850850
args.verify_length(1);
851851
std::string glyphname = Py::String(args[0]);
852852

853-
return Py::Object(Py::Long((long)
854-
FT_Get_Name_Index(face, (FT_String *) glyphname.c_str())));
853+
return Py::Long((long)
854+
FT_Get_Name_Index(face, (FT_String *) glyphname.c_str()));
855855
}
856856

857857
char FT2Font::get_ps_font_info__doc__[] =
@@ -916,7 +916,7 @@ FT2Font::get_sfnt_table(const Py::Tuple & args) {
916916
char head_dict[] = "{s:(h,h), s:(h,h), s:l, s:l, s:i, s:i,"
917917
"s:(l,l), s:(l,l), s:h, s:h, s:h, s:h, s:i, s:i, s:h, s:h, s:h}";
918918
TT_Header *t = (TT_Header *)table;
919-
return Py::Object(Py_BuildValue(head_dict,
919+
return Py::asObject(Py_BuildValue(head_dict,
920920
"version",
921921
FIXED_MAJOR(t->Table_Version),
922922
FIXED_MINOR(t->Table_Version),
@@ -944,7 +944,7 @@ FT2Font::get_sfnt_table(const Py::Tuple & args) {
944944
char maxp_dict[] = "{s:(h,h), s:i, s:i, s:i, s:i, s:i, s:i,"
945945
"s:i, s:i, s:i, s:i, s:i, s:i, s:i, s:i}";
946946
TT_MaxProfile *t = (TT_MaxProfile *)table;
947-
return Py::Object(Py_BuildValue(maxp_dict,
947+
return Py::asObject(Py_BuildValue(maxp_dict,
948948
"version",
949949
FIXED_MAJOR(t->version),
950950
FIXED_MINOR(t->version),
@@ -975,7 +975,7 @@ FT2Font::get_sfnt_table(const Py::Tuple & args) {
975975
"s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:h, s:s#, s:(llll),"
976976
"s:s#, s:h, s:h, s:h}";
977977
TT_OS2 *t = (TT_OS2 *)table;
978-
return Py::Object(Py_BuildValue(os_2_dict,
978+
return Py::asObject(Py_BuildValue(os_2_dict,
979979
"version", (unsigned)t->version,
980980
"xAvgCharWidth", t->xAvgCharWidth,
981981
"usWeightClass", (unsigned)t->usWeightClass,
@@ -1008,7 +1008,7 @@ FT2Font::get_sfnt_table(const Py::Tuple & args) {
10081008
char hhea_dict[] = "{s:(h,h), s:h, s:h, s:h, s:i, s:h, s:h, s:h,"
10091009
"s:h, s:h, s:h, s:h, s:i}";
10101010
TT_HoriHeader *t = (TT_HoriHeader *)table;
1011-
return Py::Object(Py_BuildValue(hhea_dict,
1011+
return Py::asObject(Py_BuildValue(hhea_dict,
10121012
"version",
10131013
FIXED_MAJOR(t->Version),
10141014
FIXED_MINOR(t->Version),
@@ -1031,7 +1031,7 @@ FT2Font::get_sfnt_table(const Py::Tuple & args) {
10311031
char vhea_dict[] = "{s:(h,h), s:h, s:h, s:h, s:i, s:h, s:h, s:h,"
10321032
"s:h, s:h, s:h, s:h, s:i}";
10331033
TT_VertHeader *t = (TT_VertHeader *)table;
1034-
return Py::Object(Py_BuildValue(vhea_dict,
1034+
return Py::asObject(Py_BuildValue(vhea_dict,
10351035
"version",
10361036
FIXED_MAJOR(t->Version),
10371037
FIXED_MINOR(t->Version),

unit/ft2font_memleak.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys, time, os
22
from matplotlib.numerix import rand
33
from matplotlib.ft2font import FT2Font
4+
from matplotlib.backends.backend_ps import encodeTTFasPS
45

56
fname = '/usr/local/share/matplotlib/Vera.ttf'
67

@@ -17,10 +18,13 @@ def report_memory(i):
1718
font.clear()
1819
font.set_text('hi mom', 60)
1920
font.set_size(12, 72)
21+
2022
#glyph = font.load_char(int(140*rand()))
2123
font.draw_glyphs_to_bitmap()
2224
#font.draw_glyph_to_bitmap(0, 0, glyph)
2325

26+
27+
#s = encodeTTFasPS(fname)
2428
val = report_memory(i)
2529
if i==1: start = val
2630

0 commit comments

Comments
 (0)