打开TIFF图像时的Python和内存消耗 [英] Python and memory consumption when opening TIFF images
本文介绍了打开TIFF图像时的Python和内存消耗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个程序,处理几个占用大量RAM的16位TIFF图像.
I am writing a program that deals with several 16-bit TIFF images that consumes a lot of RAM.
如果我打开这样的图像:
If I am opening images like this:
import cv2
for i in range(1000):
img = cv2.imread(file[i])
每个图像数组都存储到内存中吗,或者当我将其分配给新值时是否将其删除? 如果没有删除,如何在打开新的之前删除它?
Does each image array go to memory, or does it get deleted when I assign it to the new value? If it does not get deleted, how can I delete it before opening a new one?
谢谢!
推荐答案
对于每次迭代,都会重新分配img
,因此旧帧将被垃圾收集器自动删除.
For each iteration, img
gets reassigned, so the old frames will get deleted automatically by the garbage collector.
这篇关于打开TIFF图像时的Python和内存消耗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文