Merge pull request #243 from aftaylor2/fix_ram_info_darwin_total_mem
Fix: Avoid potential delay in calc of RAM (darwin)
This commit is contained in:
commit
3f2466af44
1 changed files with 4 additions and 1 deletions
|
@ -19,7 +19,10 @@ get_ratio()
|
||||||
Darwin)
|
Darwin)
|
||||||
# Get used memory blocks with vm_stat, multiply by page size 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 -v pagesize=$(pagesize) '{printf "%d\n", ($1+$2) * pagesize / 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}')
|
# System Profiler performs an activation lock check, which can result in
|
||||||
|
# time outs or a lagged response. (~10 seconds)
|
||||||
|
# total_mem=$(system_profiler SPHardwareDataType | grep "Memory:" | awk '{print $2 $3}')
|
||||||
|
total_mem=$(sysctl -n hw.memsize | awk '{print $0/1024/1024/1024 " GB"}')
|
||||||
if ((used_mem < 1024 )); then
|
if ((used_mem < 1024 )); then
|
||||||
echo "${used_mem}MB/$total_mem"
|
echo "${used_mem}MB/$total_mem"
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue