profmem: Profile Memory Use

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/utils.R

Description

These are utility functions for profiling memory used by objects and by R during the execution of an expression.

Usage

1
2
3
profmem(expr)

mem(x, reset = FALSE)

Arguments

expr

An expression to be evaluated.

x

An object, to identify how much memory it is using.

reset

Should the maximum memory used by R be reset?

Details

These are wrappers around the built-in gc function. Note that they only count memory managed by R.

Value

For profmem, a vector giving [1] the amount of memory used at the start of execution, [2] the amount of memory used at the end of execution, [3] the maximum amount of memory used during execution, [4] the memory overhead as defined by the maximum memory used minus the starting memory use, and [5] the execution time in seconds.

For mem, either a single numeric value giving the memory used by an object, or a vector providing a more readable version of the information returned by gc (see its help page for details).

Author(s)

Kylie A. Bemis

See Also

gc,

Examples

1
2
3
4
5
x <- 1:100

mem(x)

profmem(mean(x + 1))

Example output

Loading required package: BiocParallel
Loading required package: Matrix
Loading required package: biglm
Loading required package: DBI

Attaching package:matterThe following object is masked frompackage:biglm:

    biglm

The following objects are masked frompackage:base:

    apply, scale

bytes 
  448 
   start (MB)   finish (MB) max used (MB) overhead (MB)    time (sec) 
      154.500       154.500         0.000      -154.500         0.001 

matter documentation built on Nov. 8, 2020, 6:15 p.m.