Streamlit App Crashes Unexpectedly

Hello,

I have noticed a persistent issue with my deployed Streamlit app. The app suddenly crashes with the following (uninformative) message (and screenshot):

[manager] Error checking Streamlit healthz: Get "http://localhost:8501/healthz": dial tcp 127.0.0.1:8501: connect: connection refused
[manager] Streamlit server consistently failed status checks
[manager] Please fix the errors, push an update to the git repo, or reboot the app.

There is no issue with the code in the repository as I have made no changes plus the app runs perfect on locally on my device. Now, once I reboot the app, everything works perfectly again, then it crashes after a while. I cannot make sense of the error message so I can’t pinpoint the source.

Kindly advise. The log can be found here. Thank you.

Hi @Outsiders17711.

I’m suspecting a memory issue here, I’m also checking with our cloud engineers now to confirm this.

Out of curiosity, which libraries are you using?

Thanks,
Charly

Hello @Charly_Wargnier,

Thanks for your response. I am using the following libraries:

  • mediapipe==0.8.6
  • streamlit==0.86.0
  • numpy==1.20.2
  • opencv_contrib_python==4.4.0.46

Plus, I had to add the following in a packages.txt to get the opencv to work:

  • freeglut3-dev
  • libgtk2.0-dev
  • libgl1-mesa-glx
  • tesseract-ocr
  • libtesseract-dev
  • libtesseract4
  • tesseract-ocr-all

Thank you.

1 Like

Thanks.

Let’s see what the cloud engineers are saying.

We’ll be back to you shortly.

Best,
Charly

1 Like

Btw @Outsiders17711, can you please provide the code + Sharing URL?

Thanks,
Charly

Hello @Charly_Wargnier,

Thanks for following up.

The code can be found at this repository. The main file is streamlitMediapipe.py.

The sharing URL is: https://share.streamlit.io/outsiders17711/streamlit-mediapipe-webapp/main/streamlitMediapipe.py. The app is currently down. The latest logs are here.

Does that answer your question?

Thank you.

1 Like

Thanks @Outsiders17711!

Devs took a quick look - This is the log from Streamlit server, most likely a memory error:

2021-08-11 04:18:14,240 INFO exited: streamlit (terminated by SIGKILL; not expected)

We see in our metrics that the app has very quick spikes to ~3gb before crashing, so we would recommend you to try and work on the memory management of the app.

Good luck!

Best,
Charly

Helllo @Charly_Wargnier,

Thanks for your response and effort so far.

I’ll check out the memory management. Thanks a lot.

1 Like

You’re welcome!

Let us know how it goes! :balloon:

Charly

Hello @Charly_Wargnier ,

Thanks for the pointers. I took a look at my memory management and I found out I didn’t cache the Mediapipe classes. So, the Mediapipe models were being reread into memory every time the app ran. I fixed that and did some basic garbage collection and the app has been stable every since.

Thanks’ for the help.

1 Like

That’s great to hear @Outsiders17711!

Glad I’ve been able to help you! :slight_smile:

Best,
Charly