I have data analysis module that contains functions which call on Matplotlib pyplot API multiple times to generate up to 30 figures in each run. These figures get immediately written to disk after they are generated, and so I need to clear them from memory. Currently, at the end of each of my function, I do
import matplotlib.pyplot as plt
plt.clf()
however I'm not too sure if this statement can actually clear the memory. I'm especially concerned since I see that each time I run my module for debugging, my free memory space keeps decreasing. Can anyone please enlighten me on what I need to do to really clear my memory each time after I have written the plots to disk?
Thank you.
plt.close("all")? I have a script that creates about 60 charts with 3 axes each. I use this at the end of each iteration. Memory consumption seems normal enough. - NullDev