Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix macos free_memory calculate by using vm_stat #1396

Merged
merged 1 commit into from
Mar 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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