Memory {base}R Documentation

Memory Available for Data Storage

Description

How R manages its workspace.

mem;limits is deprecated as of R 2.14.0

Usage

mem.limits(nsize = NA, vsize = NA)

Arguments

vsize

Heap memory in bytes.

nsize

Number of cons cells.

Details

R has a variable-sized workspace which is sized automatically. These limits are mainly historical, and now used only exceptionally.

R maintains separate areas for fixed and variable sized objects. The first of these is allocated as an array of cons cells (Lisp programmers will know what they are, others may think of them as the building blocks of the language itself, parse trees, etc.), and the second are thrown on a heap of ‘Vcells’ of 8 bytes each. Each cons cell occupies 28 bytes on a 32-bit build of R, (usually) 56 bytes on a 64-bit build.

The default values are (currently) an initial setting of 350k cons cells, 6Mb of vector heap: note that the areas are not actually allocated initially: rather these values are the sizes for triggering garbage collection. Thereafter R will grow or shrink the areas depending on usage, never decreasing below the initial values.

You can find out the current memory consumption (the heap and cons cells used as numbers and megabytes) by typing gc() at the R prompt. Note that following gcinfo(TRUE), automatic garbage collection always prints memory use statistics.

The function mem.limits is deprecated: use gc instead, which reports the limits in the exceptional case that they are set.

The command-line option --max-ppsize controls the maximum size of the pointer protection stack. This defaults to 50000, but can be increased to allow deep recursion or large and complicated calculations to be done. Note that parts of the garbage collection process goes through the full reserved pointer protection stack and hence becomes slower when the size is increased. Currently the maximum value accepted is 500000.

Value

mem.limits() returns a numeric vector giving the current settings of the maxima, possibly NA (for unlimited).

See Also

An Introduction to R for more command-line options.

Memory-limits for the design limitations.

gc for information on the garbage collector and total memory usage, object.size(a) for the (approximate) size of R object a. memory.profile for profiling the usage of cons cells.


[Package base version 2.14.1 Index]