memory: bug fix

This commit is contained in:
Dylan Araps 2019-09-29 16:27:45 +03:00
parent c888f4cdca
commit ee6e1bd390

10
pfetch
View File

@ -464,7 +464,7 @@ get_pkgs() {
get_memory() { get_memory() {
case $os in case $os in
# Used memory is calculated using the following "formula" (Linux): # Used memory is calculated using the following "formula":
# MemUsed = MemTotal + Shmem - MemFree - Buffers - Cached - SReclaimable # MemUsed = MemTotal + Shmem - MemFree - Buffers - Cached - SReclaimable
# Source: https://github.com/KittyKatt/screenFetch/issues/386 # Source: https://github.com/KittyKatt/screenFetch/issues/386
Linux*) Linux*)
@ -492,7 +492,7 @@ get_memory() {
mem_full=$((mem_full / 1024)) mem_full=$((mem_full / 1024))
;; ;;
# Used memory is calculated using the following "formula" (MacOS): # Used memory is calculated using the following "formula":
# (wired + active + occupied) * 4 / 1024 # (wired + active + occupied) * 4 / 1024
Darwin*) Darwin*)
mem_full=$(($(sysctl -n hw.memsize) / 1024 / 1024)) mem_full=$(($(sysctl -n hw.memsize) / 1024 / 1024))
@ -542,8 +542,8 @@ get_memory() {
EOF EOF
;; ;;
# Used memory is calculated using the following "formula" (FreeBSD): # Used memory is calculated using the following "formula":
# (inactive_count + free_count + cache_count) * page_size / 1024 # mem_full - ((inactive + free + cache) * page_size / 1024)
FreeBSD*|DragonFly*) FreeBSD*|DragonFly*)
mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024)) mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024))
@ -566,7 +566,7 @@ get_memory() {
# $2: vm.stats.vm.v_inactive_count # $2: vm.stats.vm.v_inactive_count
# $3: vm.stats.vm.v_free_count # $3: vm.stats.vm.v_free_count
# $4: vm.stats.vm.v_cache_count # $4: vm.stats.vm.v_cache_count
mem_used=$((($2 + $3 + $4) * $1 / 1024 / 1024)) mem_used=$((mem_full - (($2 + $3 + $4) * $1 / 1024 / 1024)))
;; ;;
NetBSD*) NetBSD*)