release_memory: Release Memory Back to the OS

View source: R/release_memory.R

release_memoryR Documentation

Release Memory Back to the OS

Description

Runs full garbage collection and, on Linux/glibc, calls malloc_trim(0) to return free heap pages to the operating system. Useful after large temporary matrices are removed in memory-heavy RAS pipeline stages.

Usage

release_memory(verbose = TRUE)

Arguments

verbose

Logical. If TRUE (default), prints a one-line message with the malloc_trim return value so RSS changes can be monitored in pipeline logs.

Details

On non-Linux platforms the C call is skipped and NA is returned silently; no error is raised.

Value

Invisibly returns the malloc_trim(0) result: 1 if heap pages were returned to the OS, 0 if nothing was returned, NA_integer_ on non-Linux platforms.


RAS documentation built on July 24, 2026, 5:06 p.m.