Rprofmem

0th

Percentile

Enable Profiling of R's Memory Use

Enable or disable reporting of memory allocation in R.

Keywords
utilities
Usage
Rprofmem(filename = "Rprofmem.out", append = FALSE, threshold = 0)
Arguments
filename

The file to be used for recording the memory allocations. Set to NULL or "" to disable reporting.

append

logical: should the file be over-written or appended to?

threshold

numeric: allocations on R's "large vector" heap larger than this number of bytes will be reported.

Details

Enabling profiling automatically disables any existing profiling to another or the same file.

Profiling writes the call stack to the specified file every time malloc is called to allocate a large vector object or to allocate a page of memory for small objects. The size of a page of memory and the size above which malloc is used for vectors are compile-time constants, by default 2000 and 128 bytes respectively.

The profiler tracks allocations, some of which will be to previously used memory and will not increase the total memory use of R.

Value

None

Note

The memory profiler slows down R even when not in use, and so is a compile-time option. (It is enabled in a standard Windows build of R.) The memory profiler can be used at the same time as other R and C profilers.

See Also

The R sampling profiler, Rprof also collects memory information.

tracemem traces duplications of specific objects.

The "Writing R Extensions" manual section on "Tidying and profiling R code"

Aliases
  • Rprofmem
Examples
library(utils) # NOT RUN { ## not supported unless R is compiled to support it. Rprofmem("Rprofmem.out", threshold = 1000) example(glm) Rprofmem(NULL) noquote(readLines("Rprofmem.out", n = 5)) # }
Documentation reproduced from package utils, version 3.4.3, License: Part of R 3.4.3

Community examples

Looks like there are no examples yet.