The attached script gives a quick and simple illustration of the pdf
backend memory leak noted earlier by Paul Kienzle. It seems to be
entirely related to rendering text. Adding axes, lines, and images does
not seem to matter, except insofar as adding an axes will trigger the
rendering of text for the tick labels. The leak per loop is roughly
proportional to the number of *different* characters being
rendered--about 100 bytes per character.
I don't think I could find the leak in any reasonable time; I hope
someone else who is more familiar with the pdf backend and more clever
at such things will be able to track it down ASAP.
Eric
#!/usr/bin/env python
import os, sys, time, gc
import matplotlib
matplotlib.use('pdf')
from matplotlib.cbook import report_memory
from matplotlib.pyplot import figure, show, close
# take a memory snapshot on indStart and compare it with indEnd
indStart, indEnd = 200, 1001 #200, 401
fig = figure(1)
for i in range(indEnd):
fig.clf()
#fig.suptitle("0123456789") # 1380 bytes/loop
#fig.suptitle("0123456789abcdefghik") # 2527 bytes/loop
fig.suptitle("01234567890123456789") # 1331 bytes/loop
fig.savefig('tmp%d' % i, dpi = 75)
close(1) # This doesn't make any difference in the leak
gc.collect()
val = report_memory(i)
print i, val
if i==indStart: start = val # wait a few cycles for memory usage to stabilize
end = val
print 'Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart))
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel