St.image causing memory leak due to _PIL_to_bytes()

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

Can you format your code properly?

if i create a empty placeholder named st_frame and put st_frame.image() in a long running loop , memory leak is happening.
trace is showing root cause as line no 237 (of image.py of streamlit module ) , the function _PIL_to_bytes() is causing this , not releasing memory

st_frame=st.empty()
while ( x<100000):
st_frame.image(cv2.resize(res_plotted, (540, 340)) , caption=‘Detected Video’, channels=“BGR”)