object.size              package:utils              R Documentation

_R_e_p_o_r_t _t_h_e _S_p_a_c_e _A_l_l_o_c_a_t_e_d _f_o_r _a_n _O_b_j_e_c_t

_D_e_s_c_r_i_p_t_i_o_n:

     Provides an estimate of the memory that is being used to store an
     R object.

_U_s_a_g_e:

     object.size(x)

_A_r_g_u_m_e_n_t_s:

       x: An R object.

_D_e_t_a_i_l_s:

     Exactly which parts of the memory allocation should be attributed
     to which object is not clear-cut.  This function merely provides a
     rough indication: it should be reasonably accurate for atomic
     vectors, but does not detect if elements of a list are shared, for
     example. (As from R 2.0.0 sharing amongst elements of a character
     vector is taken into account.)

     The calculation is of the size of the object, and excludes the
     space needed to store its name in the symbol table.

     Object sizes are larger on 64-bit platforms than 32-bit ones, but
     will very likely be the same on different platforms with the same
     word length.

_V_a_l_u_e:

     An estimate of the memory allocation attributable to the object,
     in bytes.

_S_e_e _A_l_s_o:

     'Memory-limits' for the design limitations on object size.

_E_x_a_m_p_l_e_s:

     object.size(letters)
     object.size(ls)
     ## find the 10 largest objects in base
     z <- sapply(ls("package:base"), function(x) object.size(get(x, envir=NULL)))
     as.matrix(rev(sort(z))[1:10])

