Skip to content

Commit

Permalink
Fix macos free_memory calculate by using vm_stat (#1396)
Browse files Browse the repository at this point in the history
  • Loading branch information
coderzc authored Mar 19, 2021
1 parent 3d73961 commit 4c4b770
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions hugegraph-dist/src/assembly/static/bin/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ function free_memory() {
free=`expr $mem_free + $mem_buffer + $mem_cached`
free=`expr $free / 1024`
elif [ "$os" == "Darwin" ]; then
free=`top -l 1 | head -n 10 | grep PhysMem | awk -F',' '{print $2}' \
| awk -F'M' '{print $1}' | tr -d " "`
local pages_free=`vm_stat | awk '/Pages free/{print $0}' | awk -F'[:.]+' '{print $2}' | tr -d " "`
local pages_inactive=`vm_stat | awk '/Pages inactive/{print $0}' | awk -F'[:.]+' '{print $2}' | tr -d " "`
local pages_available=`expr $pages_free + $pages_inactive`
free=`expr $pages_available \* 4096 / 1024 / 1024`
else
echo "Unsupported operating system $os"
exit 1
Expand Down

0 comments on commit 4c4b770

Please sign in to comment.