Menu

[r4636]: / branches / transforms / unit / ft2font_memleak.py  Maximize  Restore  History

Download this file

35 lines (26 with data), 874 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import sys, time, os
from matplotlib.numerix import rand
from matplotlib.ft2font import FT2Font
from matplotlib.backends.backend_ps import encodeTTFasPS
fname = '/usr/local/share/matplotlib/Vera.ttf'
def report_memory(i):
pid = os.getpid()
a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()
print i, ' ', a2[1],
return int(a2[1].split()[0])
fname = '/usr/local/share/matplotlib/Vera.ttf'
N = 400
for i in range(N):
font = FT2Font(fname)
font.clear()
font.set_text('hi mom', 60)
font.set_size(12, 72)
#glyph = font.load_char(int(140*rand()))
font.draw_glyphs_to_bitmap()
#font.draw_glyph_to_bitmap(0, 0, glyph)
#s = encodeTTFasPS(fname)
val = report_memory(i)
if i==1: start = val
end = val
print 'Average memory consumed per loop: %1.4f\n' % ((end-start)/float(N))
# Average memory consumed per loop: 0.09
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.