I'm trying to debug memory issues in a shiny application. I've used profvis on my own machine, and it seems its memory footprint is fairly low, so I'm not sure why I'm getting "Out of memory" errors on shinyapps.io. In order to help me debug, is there a virtual machine image I can download to simulate the shinyapps.io environment with restricted memory, etc?
Hello Richard, I don't have a virtual machine image for you, but until someone else can hop in and provide one I can offer a suggestion that may or may not help you.
I've had some success myself depending on project using the logger
package to help me produce logs for my apps
Introduction to logger • logger (daroczig.github.io)
Its particularly helpful with shiny apps as it has a function log_shiny_input_changes
that can help to determine what the user has done in the app.
Beyond that pryr
package has mem_used
function
so if you sprinkle some log_info()
calls involving mem_used
in your code this can be a way to determine what is happening at least to some extent.
Whether a memory footprint is large or not is very relative let a lone subjective. Depending on the plan you are using at shinyapps.io (cf. RAM size for different shinyapps.io plans) you are limited by 1GB (starter) or 8 GB for the other plans.
I got a basic plan and I've cranked the ram up to 8gb, but I'm still getting "out of memory" issues and need to restart the server every day or so to get it working again. I'd like to debug these issues.
Sorry the the slow reply here - I think the best really would be to follow @nirgrahamuk advice and start doing memory profiling of your shiny app. You either are using a package that creates a memory leak or you are for some reason allocating memory without ever deallocating it again.
In the metrics page of your app (e.g. https://www.shinyapps.io/admin/#/application/.../metrics
) you should see the increase in memory use. Is this linear or step-wise ? Is it triggered by some specific operations ?
If nothing of the above helps, would you be able to create a reproducible example which we could analyse on our side ?
Also maybe take a look at Memory usage · Advanced R. where some possible ways to create memory leaks in code are referenced.