

   gc {base}                                    R Documentation

   GGaarrbbaaggee CCoolllleeccttiioonn

   DDeessccrriippttiioonn::

        A call of `gc' causes a garbage collection to take
        place.  `gcinfo' sets a flag so that automatic collec-
        tion is either silent (`verbose=FALSE') or prints mem-
        ory use statistics (`verbose=TRUE').

   UUssaaggee::

        gc(verbose = .Options$verbose)
        gcinfo(verbose)

   AArrgguummeennttss::

    verbose: logical; if `TRUE', the garbage collection prints
             statistics about cons cells [in Bytes] and the
             vector heap [in KBytes].

   DDeettaaiillss::

        A call of `gc' causes a garbage collection to take
        place.  This takes place automagically without user
        intervention, and the primary purpose of calling `gc'
        is for the report on memory usage.

   VVaalluuee::

        `gc' returns a 2*3 matrix with rows `"Ncells"' (cons
        cells, usually 20 bytes each on 32-bit systems, 36
        bytes each on 64-bit systems) and `"Vcells"' (vector
        cells, 8 bytes each), and columns `"free"', `"total"'
        and `"(Mb)"' (rounded up to the next 0.1Mb).

        `gcinfo' returns the previous value of the flag.

   SSeeee AAllssoo::

        `Memory' on R's memory management  and `gctorture' if
        you are an R hacker.

   EExxaammpplleess::

        gc() #- do it now
        gcinfo(TRUE) #-- in the future, show when R does it
        x <- 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 percentages
        rgc[2,"free"]/ (1024 / 8) # free vector heap in K bytes

