Rev 7888 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{gc}\title{Garbage Collection}\usage{gc(verbose = getOption("verbose"))gcinfo(verbose)}\alias{gc}\alias{gcinfo}\arguments{\item{verbose}{logical; if \code{TRUE}, the garbage collection printsstatistics about cons cells [in Bytes] and the vector heap [in KBytes].}}\description{A call of \code{gc} causes a garbage collection to take place.\code{gcinfo} sets a flag so thatautomatic collection is either silent (\code{verbose=FALSE}) orprints memory use statistics (\code{verbose=TRUE}).}\details{A call of \code{gc} causes a garbage collection to take place.This takes place automagically without user intervention, and theprimary purpose of calling \code{gc} is for the report on memory usage.}\value{\code{gc} returns a 2*3 matrix with rows \code{"Ncells"} (\emph{conscells}, usually 20 bytes each on 32-bit systems, 36 bytes each on64-bit systems) and \code{"Vcells"} (\emph{vector cells}, 8 bytes each),and columns \code{"free"}, \code{"total"} and \code{"(Mb)"} (rounded upto the next 0.1Mb).\code{gcinfo} returns the previous value of the flag.}\seealso{\code{\link{Memory}} on \R's memory management and\code{\link{gctorture}} if you are an \R hacker.}\examples{gc() #- do it nowgcinfo(TRUE) #-- in the future, show when R does itx <- integer(0); for(i in 1:18) x <- c(x,i,x)gcinfo(verbose = FALSE)#-- don't show it anymore( rgc <- gc(TRUE) )(100*rgc[,"free"])\%/\% rgc[,"total"] # the percentagesrgc[2,"free"]/ (1024 / 8) # free vector heap in K bytes}\keyword{environment}