Streamlit memory leak with st.image

Streamlit 1.42.2, python3.10 (running in python:3.10-slim container)

I have a simple code like below:

import streamlit as st
import numpy as np
import time
while True:
    frame = np.random.randint(0, 256, (1920, 1080, 3), dtype=np.uint8)
    st.image(frame, channels="RGB")
    time.sleep(0.1)

The above code is just an example, simulating previewing a video cap, but still - its enough to see the problem.

I’m running top to see resources usage and unfortunately I see a memory leak.

Do You have any idea how to fix it?

Take a look at this comment in the issue tracker:

Read also the other comments and the links, they can provide workarounds.