-
Notifications
You must be signed in to change notification settings - Fork 14
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 #708
Memory #708
Conversation
isolate renderLeaflet so the map isn't redrawn when the region$plot changes
Now region$plot is reactive these aren't needed
This means we store the processed files globally
I navigated to Hampshire on multiple different browser windows and recorded memory usage in R by
So now you can see multiple sessions adds hardly anything to the total MB of R objects! I've added a cap so that objects are removed from the global list if there are more than 100 and they are removed last accessed == first removed. This is because I don't want that global list to get too large (loading all the rds files is ~ 15Gb). This will need testing as I've also made |
Thanks @nikolai-b I just took a look at the code, looks clever. Look forward to testing this when back home next week. Have asked a few questions in the meantime. I suggest that if it passes informal tests by me and @usr110 we get others to test it on the test server with a before/after merge. Sound reasonable? I think this could make the app way more tolerant of many users so great work! |
I've tested on the latest version with the new tiles in all scenarios for commuting and schools and for multiple regions. Aside for making large regions load faster, I think, I can see no change. So merging. Great work @nikolai-b, many thanks! |
filepath <- file.path(base_path, filename) | ||
|
||
while (length(loaded_data) > 100) { # Rm objects from the list when too many (by time last accessed) | ||
loaded_data[[names(loaded_data_accessed[loaded_data_accessed == min(unlist(loaded_data_accessed))])]] <<- NULL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does min(unlist(loaded_data_accessed))
here do?
rds <- readRDS(filepath) | ||
if(filename == "rnet.Rds") { | ||
if(!is.null(rds)){ | ||
rds$id <- rds$local_id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry you've had to do that. We should have called it id
initially I think but not worth changing now.
if(filename == "rq.Rds"){ | ||
# Merge in scenario data for quiet routes - don't want this in download but need for line sorting | ||
rds@data <- cbind( | ||
rds@data[!(names(rds) %in% names(str_lines))], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shows that shifting from sp
to sf
would be a massive operation. Not worth it now.
Ref #707
This isn't ready but it shows the basic idea.