My app crashes after some time being deployed in Share Streamlit

Hi everybody,

I have deployed my streamlit app in streamlitshare, but for some reason, after some time (and I guess when several users are using it at the same time), it crashes. My guess is that my code is not optimizing ressources.

I am really struggling to know what part of the code is creating the issue, can somebody give me any kind of hint?

Here is the code:

And here is the code deployed that will crash after some use:

Thanks in advance.