Learn R Programming

mvbutils (version 2.8.232)

lsize: Report objects and their memory sizes

Description

lsize is like ls, except it returns a numeric vector whose names are the object names, and whose elements are the object sizes. The vector is sorted in order of increasing size. lsize avoids loading objects cached using mlazy; instead of their true size, it uses the size of the file that stores each cached object, which is shown as a negative number. The file size is typically smaller than the size of the loaded object, because mlazy saves a compressed version. NB that lsize will scan all objects in the environment, including ones with funny names, whereas ls does so only if its all.names argument is set to TRUE.

Usage

lsize( envir=.GlobalEnv)

Arguments

envir

where to look for the objects. Will be coerced to environment, so that e.g. lsize( 2) and lsize( "package:mvbutils") work. envir can be a sys.frame-- useful during debugging.

Value

Named numeric vector.

See Also

ls, mlazy

Examples

Run this code
# NOT RUN {
# Current workspace
lsize()
# Contrived example to show objects in a function's environment
{function(..., a, b, c) lsize( sys.frame( sys.nframe())) }()
# a, b, c are all missing; this example might break in future R versions
# ...   a   b   c
#  28  28  28  28
# }

Run the code above in your browser using DataLab