Hello,
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,
Tom
#print global environment objects
env <- globalenv() # can use globalenv(), parent.frame(), etc
output$foo <- renderTable({
data.frame(
object = ls(env),
size = unlist(lapply(ls(env), function(x) {
object.size(get(x, envir = env, inherits = FALSE))
})))
})```
Output:
|object|size|
|---|---|
|distance_sf|1051640.00|
|dogs|16498000.00|
|euth_sf|897600.00|
|layer_90th|261968.00|
|layer_count|256528.00|
|layer_distance|261312.00|
|layer_euth_all|223760.00|
|layer_euth_owner|223744.00|
|layer_euth_stray|223728.00|
|layer_foreign|355424.00|
|layer_house_val|363856.00|
|layer_income|363856.00|
|layer_long_rate|158560.00|
|layer_meanLOS|324224.00|
|layer_pov_100|355424.00|
|layer_pov_149|355408.00|
|layer_rto|262240.00|
|layer_unemployed|355408.00|
|longadopt_sf|626032.00|
|LOS_sf|1409288.00|
|m_census|6405736.00|
|m_counts|2781992.00|
|m_dist|2775400.00|
|m_euth|3533408.00|
|m_los|2667728.00|
|sf_census|649296.00|
|tracts_geometry|1935848.00|
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