plt.clf()
plt.figure().clear()
plt.close()
plt.close(fig)
plt.close('all')
None of these lines which are solutions that I find in stack overflow like this one When to use cla(), clf() or close() for clearing a plot in matplotlib? work for me and I constantly get MemoryError:
or tkinter.TclError: not enough free memory for image buffer
I used them at the end of my loop which plotted figures.
for i in range(1000):
fig, axs = plt.subplots(2,figsize=(12, 8), dpi=400, facecolor='w', edgecolor='k')
axs[0].plot([0,1],[2,3])
axs[1].plot([0,1],[2,3])
plt.savefig("a.png")
plt.clf()
plt.figure().clear()
plt.close()
plt.close(fig)
plt.close('all')
What else can I do? And can you tell me is it a bug so it's gonna be debugged later which it doesn't seem to. so how my problem can be described (you may think why I'm asking you??!), cause there are really none possibilities that I had written those lines wrong or put it wrong where.