Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leak with reactiveTimer and invalidateLater #2021

Closed
jcheng5 opened this issue Apr 18, 2018 · 0 comments
Closed

Memory leak with reactiveTimer and invalidateLater #2021

jcheng5 opened this issue Apr 18, 2018 · 0 comments

Comments

@jcheng5
Copy link
Member

jcheng5 commented Apr 18, 2018

(Reported by Aaron Berg on behalf of a customer)

If a session ends while a timer (reactiveTimer or invalidateLater) is pending, the memory used by the session will be retained until the timer's next timeout. For apps that have very long timeouts (such as refreshing data on a dashboard app every 24 hours), lots of data, and frequent browser refreshes (or lots of visitors coming and going), this can lead to significant memory leakage.

The examples below demonstrate the problem, one for each type of timer. Reload the app many times in succession and you'll see that the RAM usage climbs with each refresh. If you wait until the 100 second timeouts start expiring, you'll see the RAM usage start to decline.

library("shiny")

ui <- function(req) {
  basicPage(
    "Memory usage is ",
    capture.output(print(pryr::mem_used()))
  )
}

server <- function(input, output, session) {
  session$userData$data <- runif(1000000)
  isolate(invalidateLater(100*1000))
}

shinyApp(ui,server)
library("shiny")

ui <- function(req) {
  basicPage(
    "Memory usage is ",
    capture.output(print(pryr::mem_used()))
  )
}

server <- function(input, output, session) {
  session$userData$data <- runif(1000000)
  reactiveTimer(100*1000)
}

shinyApp(ui,server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants