Is this a good practice to include this piece of code while building shiny applications

Hi all,

I just came across this piece of code where in while we are building shiny applications, we can incorporate this at any point to see what is the memory used by the objects and its class. For example, I am building a shiny app, in the middle, after lot of data wrangling, I put this piece of code


###### shiny app 
  memory_data <- as.data.frame(sapply(ls(), function(x){object.size(x)}))
  colnames(memory_data) <- "Size"
  memory_data$object <- row.names(memory_data)
  rownames(memory_data) <- NULL
  memory_data <- memory_data[order(memory_data$Size),]
  
  
  x <- lapply(mget(ls()), class) 
  x <- as.data.frame(data.table(row.names = names(x), class = x))
  colnames(x) <- c("object", "class")
  
  memory_database <- left_join(memory_data, x)
  fwrite(memory_database,"memory_datsa.csv")

## shiny app contd....

So i get the list where I have to remove the objects so that memory consumption is reduced.
Am I correct?

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.