返回列表 发帖

[问题求助] Python怎样清理占用的内存?【己解决】

本帖最后由 keshun 于 2021-11-5 10:42 编辑
import matplotlib.pyplot as plt
def aa():
    plt.figure(figsize=(50, 20), dpi=300)
    plt.savefig('1.jpg')
    plt.clf() ; plt.close('all')
aa()
input("关闭窗口")COPY
代码循环运行,matplotlib模块aa()只开始运行一次,占用几百兆内存不能释放,请教高手怎样清理占用的内存?

本帖最后由 keshun 于 2021-11-6 00:52 编辑
http://www.bathome.net/thread-23875-1-1.html
if os.path.exists(r'empty.exe'): subprocess.Popen('empty *',stdout = subprocess.PIPE)
else: print(' 内存清理失败!缺少[empty.exe]')COPY

TOP

返回列表