memory usage increases during for loop in my python script

In my python script, I found the memory usage gradually increases in a loop, although no increase of the memory usage  seems required by what I wanted to do.

 

What increased the memory usage without my intention was a large number of figure objects  created in the loop. The following sentenses after plt.savefig(figfile) fixed the problem.

plt.clf()

plt.close()