R: Torture Garbage Collector

gctorture {base} | R Documentation

## Torture Garbage Collector

### Description

Provokes garbage collection on (nearly) every memory allocation. Intended to ferret out memory protection bugs. Also makes R run very slowly, unfortunately.

### Usage

    gctorture(on = TRUE)
    gctorture2(step, wait = step, inhibit_release = FALSE)

### Arguments

`on` | logical; turning it on/off.
`step` | integer; run GC every `step` allocations; `step = 0` turns the GC torture off.
`wait` | integer; number of allocations to wait before starting GC torture.
`inhibit_release` | logical; do not release free objects for re-use: use with caution.

### Details

Calling `gctorture(TRUE)` instructs the memory manager to force a full GC on every allocation. `gctorture2` provides a more refined interface that allows the start of the GC torture to be deferred and also gives the option of running a GC only every `step` allocations.

The third argument to `gctorture2` is only used if R has been configured with a strict write barrier enabled. When this is the case all garbage collections are full collections, and the memory manager marks free nodes and enables checks in many situations that signal an error when a free node is used. This can greatly help in isolating unprotected values in C code. It does not detect the case where a node becomes free and is reallocated. The `inhibit_release` argument can be used to prevent such reallocation. This will cause memory to grow and should be used with caution and in conjunction with operating system facilities to monitor and limit process memory use.

### Value

Previous value of first argument.

### Author(s)

Peter Dalgaard and Luke Tierney

[Package base version 2.15.1 Index]