Merge pull request #741 from konimex/freebsdmem
Memory [FreeBSD]: Fix inaccurate free memory calculation
This commit is contained in:
commit
2e65f48eaa
7
neofetch
7
neofetch
|
@ -1257,8 +1257,11 @@ get_memory() {
|
||||||
case "$kernel_name" in
|
case "$kernel_name" in
|
||||||
"NetBSD"*) mem_free="$(($(awk -F ':|kB' '/MemFree:/ {printf $2}' /proc/meminfo) / 1024))" ;;
|
"NetBSD"*) mem_free="$(($(awk -F ':|kB' '/MemFree:/ {printf $2}' /proc/meminfo) / 1024))" ;;
|
||||||
"FreeBSD"* | "DragonFly"*)
|
"FreeBSD"* | "DragonFly"*)
|
||||||
mem_free="$(top -d 1 | awk -F ',' '/^Mem:/ {print $5}')"
|
hw_pagesize="$(sysctl -n hw.pagesize)"
|
||||||
mem_free="${mem_free/M Free}"
|
mem_inactive="$(($(sysctl -n vm.stats.vm.v_inactive_count) * hw_pagesize))"
|
||||||
|
mem_unused="$(($(sysctl -n vm.stats.vm.v_free_count) * hw_pagesize))"
|
||||||
|
mem_cache="$(($(sysctl -n vm.stats.vm.v_cache_count) * hw_pagesize))"
|
||||||
|
mem_free="$(((mem_inactive + mem_unused + mem_cache) / 1024 / 1024))"
|
||||||
;;
|
;;
|
||||||
"MINIX")
|
"MINIX")
|
||||||
mem_free="$(top -d 1 | awk -F ',' '/^Memory:/ {print $2}')"
|
mem_free="$(top -d 1 | awk -F ',' '/^Memory:/ {print $2}')"
|
||||||
|
|
Reference in New Issue