Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

jmemprof

rJava memory profiler


Description

.jmemprof enables or disables rJava memory profiling. If rJava was compiled without memory profiling support, then a call to this function always causes an error.

Usage

.jmemprof(file = "-")

Arguments

file

file to write profiling information to or NULL to disable profiling

Details

The file parameter must be either a filename (which will be opened in append-mode) or "-" to use standard output or NULL to disable profiling. An empty string "" is equivalent to NULL in this context.

Note that lots of finalizers are run only when R exists, so usually you want to enable profiling early and let R exit to get a sensible profile. Running gc may be helpful to get rid of references that can be collected in R.

A simple perl script is provided to analyze the result of the profiler. Due to its simple text format, it is possible to capture entire stdout including the profiler information to have both the console context for the allocations and the profile. Memory profiling is also helpful if rJava debug is enabled.

Note that memory profiling support must be compiled in rJava and it is by default compiled only if debug mode is enabled (which is not the case by default).

Value

Returns NULL.

Examples

## memory profiling support is optional so only works when enabled
tryCatch(
.jmemprof("rJava.mem.profile.txt"),
error=function(e) message(e))

rJava

Low-Level R to Java Interface

v1.0-4
LGPL-2.1
Authors
Simon Urbanek <simon.urbanek@r-project.org>
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.