Skip to contents
  • free_memory_gb() returns the memory available for new processes (MemAvailable of /proc/meminfo on Linux), in gigabytes.

  • check_free_memory() stops when it falls below a minimum. Call it before a heavy step (a large aggregation, an OCR run, a language model): two heavy jobs at once exhaust the machine.

Usage

free_memory_gb()

check_free_memory(min_gb = 4)

Arguments

min_gb

Number. Minimal available memory, in gigabytes.

Value

free_memory_gb(): gigabytes (NA where /proc/meminfo does not exist). check_free_memory(): the available memory, invisibly.

Details

Available memory counts the file cache that the system can release; it is what a new process can use without swapping. DuckDB's memory limit should stay well below it (see db_connect()): DuckDB spills to disk beyond its limit, whereas a process that exceeds the available memory is killed.

See also

Examples

free_memory_gb()
#> [1] 19.00926
check_free_memory(min_gb = 0)