循环保存Matplotlib图时发生内存溢出
问题内容:
我正在使用一个迭代循环使用Matplotlib绘制soame数据。当代码保存了大约768个图时,将引发以下异常。
RuntimeError: Could not allocate memory for image
我的电脑有大约3.5 GB的RAM。有什么方法可以并行释放内存,以免耗尽内存?
问题答案:
close
完成数据后,您是否还记得数字?例如:
import matplotlib.pyplot as plt
#generate figure here
#...
plt.close(fig) #release resources associated with fig