[英]How to free ram in python
I have a simple code 我有一个简单的代码
import cv2
import numpy as np
Image = cv2.imread('blue.jpg')
Threshold = np.zero
s(Image.shape, np.uint8)
cv2.threshold(Image, 121, 255, cv2.THRESH_BINARY, Threshold)
cv2.imshow("WindowName", Threshold )
cv2.waitKey(0)
cv2.destroyAllWindows()
I want to delete matrix 我想删除矩阵
"Image" “图片”
from memeory ie clear memory to save space in ram 从内存即清除内存以节省内存空间
How can i acheive this i am working this code on raspberry pi so 我如何才能做到这一点我正在树莓派上工作此代码
del Image
will likely do what you want, but there are some special cases. del Image
可能会做您想要的事情,但是有一些特殊情况。
Image
(it may be freed at some later point, or maybe not at all) 如果Image
有一个循环引用,它不会立即做任何事情(它可能在以后释放,或者根本不释放) del
to be a suggestion. 认为del
是一个建议。 You may want to use 您可能要使用
del Image[:]
del Image
Actually , you don't need to do and even don't need to care about it. 实际上 ,您不需要做,甚至不需要关心它。
Python automatically frees all objects that are not referenced any more Python自动释放所有不再引用的对象
Refer this with very quality accepted answer how to release used memory immediately in python list? 用质量非常好的答案引用此内容如何在python列表中立即释放使用的内存?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.