gc                   package:base                   R Documentation

_G_a_r_b_a_g_e _C_o_l_l_e_c_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

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

_U_s_a_g_e:

     gc(verbose = getOption("verbose"))
     gcinfo(verbose)

_A_r_g_u_m_e_n_t_s:

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

_D_e_t_a_i_l_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_a_l_u_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_e_e _A_l_s_o:

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

_E_x_a_m_p_l_e_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

