gc(verbose = getOption("verbose"), reset = FALSE) gcinfo(verbose)
- logical; if
TRUE, the garbage collection prints statistics about cons cells and the space allocated for vectors.
- logical; if
TRUEthe values for maximum space used are reset to the current values.
However, it can be useful to call
gc after a large object has been removed, as this may prompt R to return memory to the operating system.
R allocates space for vectors in multiples of 8 bytes: hence the report of
"Vcells", a relict of an earlier allocator (that used a vector heap).
gcinfo(TRUE) is in force, messages are sent to the message connection at each garbage collection of the form
Garbage collection 12 = 10+0+2 (level 0) ... 6.4 Mbytes of cons cells used (58%) 2.0 Mbytes of vectors used (32%)
Here the last two lines give the current memory usage rounded up to the next 0.1Mb and as a percentage of the current trigger value. The first line gives a breakdown of the number of garbage collections at various levels (for an explanation see the ‘R Internals’ manual).
gc returns a matrix with rows
"Ncells" (cons cells), usually 28 bytes each on 32-bit systems and 56 bytes on 64-bit systems, and
"Vcells" (vector cells, 8 bytes each), and columns
"gc trigger", each also interpreted in megabytes (rounded up to the next 0.1Mb).
If maxima have been set for either
"Vcells", a fifth column is printed giving the current limits in Mb (with
NA denoting no limit).
The ‘R Internals’ manual.
Documentation reproduced from R 2.15.3. License: GPL-2.