Repeatedly re-defining inputs with renderUI ... should I worry about memory leaks?

Hi all, I have an architecture for a Shiny app in mind, but I'm wondering if it'll cause memory leaks, as I'm not 100% sure of Shiny's own under-the-hood architecture for this.

I have a (trivial, for the sake of example) renderUI function, like so:

output$dynamic_ui <- renderUI({
  ## the design of this input element itself takes a reactive dependency on another element
  radioButtons("radio_input", "some title", choices = input$checkbox_group_input)

My guess is that the same reactive element (input$radio_input) will continue to get re-defined, and its name serves as a unique identifier for these (potentially frequent) redefinitions.
A possibility, however, is that under-the-hood there's an additional new unique identifier assigned each time a reactive element is constructed and each successive call to the renderUI function adds to a growing list of (mostly hidden) reactive elements ... which is effectively a type of memory leak.

Any idea if my guess is correct, and the total number of reactive elements held in memory doesn't grow each time renderUI would be called?

within a given scope and namespace radio_input will be unique based on its name alone, and you will be redefining it. so no need to worry about a leak from that angle.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

However, if you're only changing the choices, updateCheckboxInput() would be a simpler alternative. You might find useful.