malloc.trim {mallinfo}R Documentation

Request memory release from the system.

Description

See malloc_trim function in your OS for details - it requests the OS memory subsystem to return any unused memory to use for the OS. This functionality is only supported by GNU C library.

Usage

malloc.trim(pad = 0L)

Arguments

pad

amount of memory (in bytes) to retain for future allocation requests

Details

This function is merely a direct call to malloc_trim in glibc, it does not trigger garbage collection, so in most cases you should call gc() first for this to have a meaningful effect of reclaiming memory.

Value

Logical, TRUE if memory was reclaimed, FALSE otherwise.

Note

By default this function is called by free() on a large enough block so in general there is no need to call this function directly. It is only meant for diagnostic purposes. Also note that glibc uses chunked allocation, so it will not release chunks that are not entriely unused - in the worst case scenario it is possible that no memory can be reclaimed even if most of it is unused.

Author(s)

Simon Urbanek

See Also

gc, mallinfo

Examples

a <- rnorm(1e7)
mallinfo()
rm(a)
gc()
malloc.trim()
mallinfo()

[Package mallinfo version 0.1-0 Index]