Skip to main content

total_memory_bytes

Function total_memory_bytes 

Source
pub fn total_memory_bytes() -> Option<u64>
Expand description

Total physical RAM on this machine in bytes, or None if it cannot be determined.

Portable by construction: sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGE_SIZE) is POSIX and answers on both Linux and macOS, and Windows has GlobalMemoryStatusEx. No new dependency — libc and windows-sys are already in the tree.

Deliberately NOT /proc/meminfo: that would repeat the Linux-only mistake this module already carries in process_rss_kb, which returns None everywhere else and so silently deactivates the memory ceiling on macOS/Windows.