Streamlit freezes and uses all computer memory and swap


I am new to streamlit, and I am creating my first app using it. The issue I am facing is that the app freezes and using the whole memory and swap on my computer.

I am creating a very simple app, and the issue happens after adding a streamlit slider (last line below).

import streamlit as st
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.ensemble import GradientBoostingRegressor

#layout design 

st.title('Country GDP Estimation Tool')
st.write('This app will estimate the GDP per capita for a country, given some attributes for that specific country as input.')

st.header('Input Attributes')
att_popl = st.slider('Population', min_value= 10000, max_value= 1400000000, value=20000000)

Here is what I am using:

  • Linux Debian 10
  • Miniconda
  • Firefox 78.4.0esr
  • Python 3.8.3
  • Streamlit, version 0.70.0

Your help is appreciated.

Hi @mbz, welcome to the community!

Well that is a pretty wide slider you are using, my browser is not able to render the underlying library either :frowning:

  • I would try to lower the number of options within the slider, by adding a step value in your slider, so you don’t enable every natural number: att_popl = st.slider('Population', min_value=1e4, max_value=1e9, value=1e7, step=1e4)
  • if you really need every value available, there’s also a number_input : st.number_input('Also population', min_value=1e4, max_value=1e9, value=1e7)

Hope one of those will help in the meantime.


1 Like

Thank you very much, that solved my problem.