枕头上的image.close()无法释放内存

时间:2019-01-25 23:23:10

标签: python-imaging-library

我正在努力从枕头图像中取消分配。

如果我运行以下命令:

@profile
def do_image_things():
  im = Image.open(foo.png')
  im.close()
  del im

然后我从Python的memory_profiler中获得以下输出:

Line #    Mem usage    Increment   Line Contents
================================================
     8   33.645 MiB   33.645 MiB   @profile
     9                             def do_image_things():
    12   37.383 MiB    3.738 MiB     im = Image.open(u'foo.png')
    13   37.387 MiB    0.004 MiB     im.close()
    14   37.387 MiB    0.000 MiB     del im

im.close()调用似乎没有取消分配Image.open()保留的内存。这是对我们注意到内存问题的大规模图像处理部署中出现的问题的简单再现。

有人能解决这个问题吗?

我正在Mac OS X上运行Pillow版本5.0.0和2.7.14。

0 个答案:

没有答案