Skip to content

Commit 4842987

Browse files
committed
correct memory on macos
- get real pagesize from sysctl rather than assuming 4K - account for inactive memory (which is a misleading name, it's still in use) - for reference: anonymous-purgeable is what Activity Monitor refers to as "App Memory", this uses sum of app+wired+compressed - result is identical to number produced by neofetch and fastfetch
1 parent ccfdc7a commit 4842987

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

nerdfetch

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,15 +300,18 @@ case $ostype in
300300
mem_full=$(($(sysctl -n hw.memsize) / 1024 / 1024))
301301
while IFS=:. read -r key val; do
302302
case $key in
303-
*' wired'* | *' active'* | *' occupied'*)
303+
'Anonymous '*|*' wired'* | *' occupied'*)
304304
mem_used=$((mem_used + ${val:-0}))
305305
;;
306+
*' purgeable'*)
307+
mem_used=$((mem_used - ${val:-0}))
308+
;;
306309
esac
307310
done <<-EOF
308311
$(vm_stat)
309312
EOF
310313

311-
mem_used=$((mem_used * 4 / 1024))
314+
mem_used=$((mem_used * $(sysctl -n vm.pagesize) / 1024 / 1024))
312315
;;
313316
*"BSD"*)
314317
mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024))

0 commit comments

Comments
 (0)