Merge pull request #119 from arturts/fix-ram-info-for-different-page-sizes
Fix $used_mem when page size is not 4Kb
This commit is contained in:
commit
ee73724f02
1 changed files with 2 additions and 2 deletions
|
@ -37,8 +37,8 @@ get_percent()
|
||||||
|
|
||||||
Darwin)
|
Darwin)
|
||||||
# percent=$(ps -A -o %mem | awk '{mem += $1} END {print mem}')
|
# percent=$(ps -A -o %mem | awk '{mem += $1} END {print mem}')
|
||||||
# Get used memory blocks with vm_stat, multiply by 4096 to get size in bytes, then convert to MiB
|
# Get used memory blocks with vm_stat, multiply by page size to get size in bytes, then convert to MiB
|
||||||
used_mem=$(vm_stat | grep ' active\|wired ' | sed 's/[^0-9]//g' | paste -sd ' ' - | awk '{printf "%d\n", ($1+$2) * 4096 / 1048576}')
|
used_mem=$(vm_stat | grep ' active\|wired ' | sed 's/[^0-9]//g' | paste -sd ' ' - | awk -v pagesize=$(pagesize) '{printf "%d\n", ($1+$2) * pagesize / 1048576}')
|
||||||
total_mem=$(system_profiler SPHardwareDataType | grep "Memory:" | awk '{print $2 $3}')
|
total_mem=$(system_profiler SPHardwareDataType | grep "Memory:" | awk '{print $2 $3}')
|
||||||
if (( $used_mem < 1024 )); then
|
if (( $used_mem < 1024 )); then
|
||||||
echo $used_mem\M\B/$total_mem
|
echo $used_mem\M\B/$total_mem
|
||||||
|
|
Loading…
Reference in a new issue