Registers a finalizer to a cluster such that the cluster will be stopped when garbage collected
Arguments
- cl
A cluster object created by for instance
makeClusterPSOCK()orparallel::makeCluster().- debug
If TRUE, then debug messages are produced when the cluster is garbage collected.
Details
The cluster is stopped using
stopCluster(cl).
An alternative to explicitly call this function on an existing
cluster object, is to create the cluster object using
makeClusterPSOCK() with argument autoStop = TRUE.
Examples
cl <- makeClusterPSOCK(2, dryrun = TRUE)
#> ----------------------------------------------------------------------
#> Manually, start worker #1 on local machine ‘localhost’ with:
#>
#> '/home/hb/shared/software/CBI/_ubuntu24_04/R-4.5.2-gcc13/lib/R/bin/Rscript' --default-packages=datasets,utils,grDevices,graphics,stats,methods -e '#label=UNKNOWN:167451:hb-x1-2025:hb' -e 'options(socketOptions="no-delay")' -e 'workRSOCK<-tryCatch(parallel:::.workRSOCK,error=function(e)parallel:::.slaveRSOCK);workRSOCK()' MASTER=localhost PORT=24724 OUT=/dev/null TIMEOUT=120 XDR=FALSE SETUPTIMEOUT=120 SETUPSTRATEGY=sequential
#>
#> ----------------------------------------------------------------------
#> Manually, start worker #2 on local machine ‘localhost’ with:
#>
#> '/home/hb/shared/software/CBI/_ubuntu24_04/R-4.5.2-gcc13/lib/R/bin/Rscript' --default-packages=datasets,utils,grDevices,graphics,stats,methods -e '#label=UNKNOWN:167451:hb-x1-2025:hb' -e 'options(socketOptions="no-delay")' -e 'workRSOCK<-tryCatch(parallel:::.workRSOCK,error=function(e)parallel:::.slaveRSOCK);workRSOCK()' MASTER=localhost PORT=24724 OUT=/dev/null TIMEOUT=120 XDR=FALSE SETUPTIMEOUT=120 SETUPSTRATEGY=sequential
#>
cl <- autoStopCluster(cl)
print(cl)
#> Socket cluster with 2 nodes on host ‘NA’ (R version and platform not queried). This cluster is registered to be automatically stopped by the garbage collector
rm(list = "cl")
gc()
#> used (Mb) gc trigger (Mb) max used (Mb)
#> Ncells 1014023 54.2 1964100 104.9 1964100 104.9
#> Vcells 1876471 14.4 8388608 64.0 5525240 42.2
