reg.finalizer(e, f, onexit = FALSE)
NULL
.
gc
and Memory
for garbage collection and
memory management.
f <- function(e) print("cleaning....")
g <- function(x){ e <- environment(); reg.finalizer(e, f) }
g()
invisible(gc()) # trigger cleanup
Run the code above in your browser using DataLab