Python matplotlib: memory not being released when specifying figure size
问题 I'm using matplotlib to generate many plots of the results of a numerical simulation. The plots are used as frames in a video, and so I'm generating many of them by repeatedly calling a function similar to this one: from pylab import * def plot_density(filename,i,t,psi_Na): figure(figsize=(8,6)) imshow(abs(psi_Na)**2,origin = 'lower') savefig(filename + '_%04d.png'%i) clf() The problem is that the memory usage of the python process grows by a couple of megabytes with every call to this