Shiny app out of memory assistance


I am running a Shiny dashboard that has 5-6 tabs, each with 1-2 plotly figures and 1-2 leaflet map objects. The app first has a simple authentication mechanism implemented with the shinymanager app, which also tells the app which dataset to load and then renders all figures and maps accordingly (called from server.R).

It was working okay until I recently added a new page with new leaflet maps that were heavier than before (~2-4mb) because of their higher granularity. Now when I load the app it makes it past the authentication but then crashes, and the logs give an out of memory error.

When I look at the files at the global environment after running the app (locally), nothing seems too heavy. See list of objects in the global environment printed below (I filtered out everything really small)

I tried to run a profvis diagnostic on my runApp command, but it consistenly failed unless the interval parameter was at least 0.5. When I did that, I seem to get only a partial look into the objects loaded, and I'm not sure how to interpret it or what goes wrong.

I was told to expect that the free tier of Shinyapps should be able to handle it, so I'd love any advice about what might I be doing wrong to cause the memory leaks and how to fix it.

Thank you,

#print global environment objects
  env <- globalenv()  # can use globalenv(), parent.frame(), etc
  output$foo <- renderTable({
      object = ls(env),
      size = unlist(lapply(ls(env), function(x) {
        object.size(get(x, envir = env, inherits = FALSE))




This is the result if I run environment() and not the global environment (these are all auxiliary functions in server.R)
object	size
census_scatter_data	4208.00
create_stray_rto_df	41536.00
df	4208.00
df_dist_hist	4208.00
df_stray_rto	4208.00
df_timeseries_in	9824.00
df_timeseries_out	11904.00
env	56.00
euth_plot_data	4208.00
input	1936.00
intake_type_options	4208.00
outcome_type_options	4208.00
output	1784.00
plot_data_los	4208.00
result_auth	1936.00
session	352.00

Hello, Tom!
Im still a beginner in R, but let me try. When i had a memory problem in a local script i used this:

memory.limit (9999999999)

I don't know if it would work in shiny environment.

Good Lucky!

Gustavo Luizon

Hi Gustavo, thanks for your suggestion. My problem is not with locally, however; it only appears when deploying thee app to Locally everything works fine.