Re: Processing repeated images and memory recovery by GC
Ivan Krylov via R-help <[email protected]>
| Newsgroups | gmane.comp.lang.r.general |
|---|---|
| Message-ID | <20250905125208.1540e379@arachnoid> |
В Thu, 4 Sep 2025 17:16:15 -0400 Steve Rowley via R-help <[email protected]> пишет: > Then I use erase.screen() to erase the previous > image, use plot() to set up a plotting area, and display the image > with rasterImage(). erase.screen() works by drawing a background-coloured rectangle over the plot, so the previous images remain in the display list despite being completely over-painted: dev.new(bg='white') split.screen(c(1,2)) # [1] 1 2 recordPlot() |> object.size() # 57584 bytes for (i in 1:2) { screen(i, FALSE) plot(0:1, 0:1, type = 'n') rasterImage(as.raster(matrix(runif(2^20), 2^10)), 0, 0, 1, 1) } recordPlot() |> object.size() |> print(units = 'Mb') # 16.2 Mb for (i in 1:2) { erase.screen(i) screen(i, FALSE) plot(0:1, 0:1, type = 'n') rasterImage(as.raster(matrix(runif(2^20), 2^10)), 0, 0, 1, 1) } recordPlot() |> object.size() |> print(units = 'Mb') # 32.3 Mb How much slower would it be to maintain your own "display list" of images and redraw the plot from scratch (e.g. using layout()) every time you change it? -- Best regards, Ivan