Rev 22985 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{reg.finalizer}\alias{reg.finalizer}\title{Finalization of objects}\description{Registers an \R{} function to be called upon garbage collection of object.}\usage{reg.finalizer(e, f)}\arguments{\item{e}{Object to finalize. Must be environment or external pointer.}\item{f}{Function to call on finalization. Must accept a single argument,which will be the object to finalize.}}\value{NULL.}\note{The purpose of this function is mainly to allow objects thatrefer to external items (a temporary file, say)to perform cleanup actions when they are nolonger referenced from within \R{}. This only makes sense for objectsthat are never copied on assignment, hence the restriction to environmentsand external pointers.}\examples{f <- function(e) print("cleaning....")g <- function(x){e<-environment(); reg.finalizer(e,f)}g()gc() # trigger cleanup}\keyword{programming}