Skip to content

Accumulated memory use in animate_frames() #145

@robe2037

Description

@robe2037

animate_frames() iterates through the frames produced by frames_spatial() and writes them incrementally to a temporary directory. The PNG graphics device is only closed at the conclusion of the loop, after all frames are rendered:

moveVis/R/animate_frames.R

Lines 113 to 119 in cf88cdc

file <- file.path(frames_dir, "frame_%05d.png")
grDevices::png(file, width = width, height = height, res = res)
graphics::par(ask = FALSE)
.lapply(1:length(frames), function(i){
quiet(print(frames[[i]]))
}, moveVis.n_cores = 1)
grDevices::dev.off()

It seems that each rendered frame persists in memory until the device is turned off and for large animations can exhaust the available memory. Fixing this may be as simple as moving the graphics rendering code inside the loop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions