Skip to content

macOS: Better approximation for AvailablePhysicalMemory

nvartolomei requested to merge nvartolomei/kwsys:macos-available_memory into master

On macOS, free pages does not seem to be a good indicatur for "available physical memory". Neither inactive ones, but it answers better questions like: "How much memory could this process use in best case scenario".

Free + Inactive aproximately matches Activity Monitor.app output.

https://developer.apple.com/library/archive/documentation/Performance/Conceptual/ManagingMemory/Articles/AboutMemory.html#//apple_ref/doc/uid/20001880-99406-TPXREF103

I can't find better documentation for this values.

Motivation behind this Merge Request is caused by CMakeFiles that limit number of compiler/linker jobs based on available memory (as reported by CMake). On my machine with 16GB RAM and ~10GB in use (as reported by Activity Monitor), CMake reports 100MB free which is correct for some definition of free, but if requested OS can give way more memory.

Edited by nvartolomei

Merge request reports

Loading