Hi,
I am using matplotlib/pyplot on my site to dynamically generate PNG
plots. And I am experiencing dramatic memory leaks. Within 10-15
hits, my Apache process grows from 15-20M to 100M.
I am using Django 1.0.2-final, Apache 2.2.1, Python 2.4.3, matplotlib
0.98.5.2. The leak happens under both Apache (with mod_wsgi 2.3) and
the development server. My OS is RHEL5.
Below is a simple code snippet that causes the leak. Please let me
know if I am doing something wrong or if there is a better way to
write this. Thanks.
from matplotlib import pyplot
def test_graph (request):
f = pyplot.figure()
ax = f.add_subplot(111)
ax.plot([1,2,3])
ax.fill_between([1,2,3],[1,2,3],[1.1,2.1,3.1])
ax.grid(True)
ax.legend(['hello'],
'upper right', shadow=True, fancybox=True)
ax.set_xlabel('Time')
ax.set_ylabel('Value ')
f.text(.5, 0.93, 'my title', horizontalalignment='center')
response = HttpResponse(content_type='image/png')
### both ways causes a leak
f.savefig( response, format = 'png' )
OR
canvas = FigureCanvas(f)
canvas.print_png(response)
canvas = None
ax = None
f = None
return response
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---