I would like to show image that is read from OpenCV.
I coded like below, but it looks memory leak occurs.
Could you tell me how to fix it? (Is it possible to delete leaking streamlit objects?)
I identified leaking objects with reference to the link below.
But I could not figure out to delete them.
Steps to reproduce
Code snippet:
import streamlit as st
import cv2
import gc
image_holder = st.empty()
capture = cv2.VideoCapture(0)
while capture.isOpened():
ret, image = capture.read()
#' A new object is created every loops
# and it leads to leaking memory.
image_holder.image(image, channels="BGR")
gc.collect()
I am under the impression that the widgets that you put in a container are not released until the app reruns, even if you substitute them for other widgets.
It is true that capture is not released either, but I see no reason for it to keep growing in size.