Brahim Bousnguar

Notes · Short note

macOS lied about my Docker memory usage

By · · 1 min read

My Mac mini dashboard's memory breakdown tries USS first, then falls back. Turns out macOS denies USS for 976 of 977 processes, so the whole donut was quietly running on RSS.

The fix: use physical footprint instead, via proc_pid_rusage → ri_phys_footprint. That's the exact number top's MEM column and Activity Monitor show. Footprint counts compressed pages at full size, so slices can now exceed "used" instead of getting scaled down to fit — when that happens they keep their real size and Other reads 0.

Ollama got its own bug: it was counted as runner footprint plus loaded model GPU memory, double-counting since a runner's footprint already holds its model's Metal buffers. Now it's the larger of the two.

On a test instance, the Docker slice read 11.22 GB against a hand-summed 11.23 GB from top. Prod had been showing 9.82 GB for the same processes after silently scaling RSS down.

143 tests pass, including a new one just for footprint math.

Plain text: mac-memory-footprint-not-rss.md · Atom feed · All notes

Contact

Say hello.

b.bousnguar@gmail.com

SAP Commerce Cloud, MuleSoft and Salesforce integration · Nantes · EN / FR