title: How to clear memory completely of all matplotlib plots
body: <p>I have a data analysis module that contains functions which call on the <code>matplotlib.pyplot</code> 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.</p>
  <p>Currently, at the end of each of my function, I do:</p>
  <pre><code>import matplotlib.pyplot as plt
  
  plt.clf()
  </code></pre>
  <p>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.</p>
  <p>What do I need to do to really clear my memory each time after I have written the plots to disk?</p>