startR devel: removing bigmemory objects with flush
- to have a function called close in startR (the user should add this function at the end of their codes)
- identify big.matrix objects created in this session
- flush them with
flush()call
The objects from bigmemory had an attribute 'package':
final_dims = c(a = 5, b = 2)
data_array <- bigmemory::big.matrix(nrow = prod(final_dims), ncol = 1)
shared_matrix_pointer <- bigmemory::describe(data_array)
class(data_array)
The objects created in Start() cannot be listed in the user session. They are internal on Start(). The files should be closed inside the corresponding function.
This lines allows to summarize the info:
print(cbind(ls(), lapply(ls(), function(x){class(get(x))})))
print(ls()[which(lapply(ls(), function(x){attributes(class(get(x)))$package}) ==
'bigmemory')])
print(length(ls()))
I have added these lines to Start() and to .LoadDataFile.
To test the result:
setwd("/esarchive/scratch/nperez/git/Flor/Nord3/")
#library(startR)
source("../source_dir.R")
source("../source_lines.R")
source_dir("/esarchive/scratch/nperez/git/Flor/Nord3/R/R/")
data <- Start(dataset = '/esarchive/exp/ecearth/a1ua/cmorfiles/DCPP/EC-Earth-Consortium/EC-Earth3/dcppA-hindcast/$member$/day/$var$/gr/v20190713/$var$_day_EC-Earth3_dcppA-hindcast_s$sdate$-$member$_gr_$fyear$.nc',
var = 'tasmin',
sdate = paste0(1961),
time = 'first',
lat = values(list(-90,90)),
lon = values(list(0,359.9)),
fyear = indices(1:5),
member = 'all',
fyear_depends = 'sdate',
return_vars = list(lat = 'dataset', lon = 'dataset'),
num_procs = 1, retrieve = TRUE)
With num_procs = 1, there is only one object from bigmemory:
"shared_matrix_pointer" "big.matrix.descriptor"