Memory profiles an R expression

Share:

Description

Memory profiles an R expression

Usage

1
2
profmem(expr, envir = parent.frame(), substitute = TRUE, threshold = 0L,
  ...)

Arguments

expr

An R expression to be evaluated and profiled.

envir

The environment in which the expression should be evaluated.

substitute

Should expr be substitute():d or not.

threshold

The smallest memory allocation (in bytes) to log.

...

Not used.

Value

An object of class Rprofmem.

See Also

Internally Rprofmem() is used.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
if (capabilities("profmem")) {

## Memory profile an R expression
p <- profmem({
  x <- raw(1000)
  A <- matrix(rnorm(100), ncol=10)
})

## Display the results
print(p)

## Total amount of memory allocation
total(p)

## Allocations greater than 1 kB
p2 <- subset(p, bytes > 1000)
print(p2)

## The expression is evaluated in the calling environment
str(x)
str(A)

}

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.