Memory                 package:base                 R Documentation

_M_e_m_o_r_y _A_v_a_i_l_a_b_l_e _f_o_r _D_a_t_a _S_t_o_r_a_g_e

_D_e_s_c_r_i_p_t_i_o_n:

     Use command line options to control the memory available for R.

_U_s_a_g_e:

     R --min-vsize=vl --max-vsize=vu --min-nsize=nl --max-nsize=nu

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

_A_r_g_u_m_e_n_t_s:

vl, vu, vsize: Heap memory in bytes.

nl, nu, nsize: Number of cons cells.

_D_e_t_a_i_l_s:

     R has a variable-sized workspace (from version 1.2.0). There is
     now much less need to set memory options than previously, and most
     users will never need to set these.  They are provided both as a
     way to control the overall memory usage (which can also be done by
     operating-system facilities such as 'limit' on Unix), and since
     setting larger values of the minima will make R slightly more
     efficient on large tasks.

     To understand the options, one needs to know that 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. 
     Effectively, the input 'v' is rounded up to the nearest multiple
     of 8.

     Each cons cell occupies 28 bytes on a 32-bit machine, (usually) 56
     bytes on a 64-bit machine.

     The '--*-nsize' options can be used to specify the number of cons
     cells and the '--*-vsize' options specify the size of the vector
     heap in bytes.  Both options must be integers or integers followed
     by 'G', 'M', 'K', or 'k' meaning 'Giga' (2^{30} = 1073741824)
     _Mega_ (2^{20} = 1048576), (computer) _Kilo_ (2^{10} = 1024), or
     regular _kilo_ (1000).

     The '--min-*' options set the minimal sizes for the number of cons
     cells and for the vector heap.  These values are also the initial
     values, but thereafter R will grow or shrink the areas depending
     on usage, but never exceeding the limits set by the '--max-*'
     options nor decreasing below the initial values.

     The default values are currently minima of 350k cons cells, 6Mb of
     vector heap and no maxima (other than machine resources). The
     maxima can be changed during an R session by calling 'mem.limits'.
     (If this is called with the default values, it reports the current
     settings.)

     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.  Maxima will never
     be reduced below the current values for triggering garbage
     collection, and attempts to do so will be silently ignored.

     When using 'read.table', the memory requirements are in fact
     higher than anticipated, because the file is first read in as one
     long string which is then split again.  Use 'scan' if possible in
     case you run out of memory when reading in a large table.

_V_a_l_u_e:

     'mem.limits()' returns an integer vector giving the current
     settings of the maxima, possibly 'NA'.

_N_o_t_e:

     For backwards compatibility, options '--nsize' and '--vsize' are
     equivalent to '--min-nsize' and '--min-vsize'.

_S_e_e _A_l_s_o:

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

_E_x_a_m_p_l_e_s:

     # Start R with 10MB of heap memory and 500k cons cells, limit to
     # 100Mb and 1M cells
     ## Not run: 
     ## Unix
     R --min-vsize=10M --max-vsize=100M --min-nsize=500k --max-nsize=1M
     ## End(Not run)

