I am using the below code . the memory leak continues , and after 6/7 hours , it is Out of memory error. The tracemalloc.take_snapshot shows that line 237 of image.py of streamlit is gradually holding memory as the loop progresses.
however there is no error if i delete or comment out the st_frame.image line.
the code looks like this:
def _display_detected_frames(conf, model,fmodel, st_frame, image):
image = image[y:y1,x:x1]
res = model.track(image, …) #parameters are there
res_plotted = res.plot(labels=True ,conf=False )
st_frame.image(cv2.resize(res_plotted, (540, 340)) , caption=‘Detected Video’, channels=“BGR”)
…
x=0
st_frame=st.empty()
While x <= 200000:
####codes of video capture of rtsp
_display_detected_frames(conf, model,fmodel, st_frame, image)
x += 1