Skip to content

Commit

Permalink
Fix for JENA-1356
Browse files Browse the repository at this point in the history
Generalize free memory detection on OS X to cope with different free
memory units based upon approach suggested by Joshua Portway
  • Loading branch information
rvesse committed Jun 9, 2017
1 parent 3baf1a3 commit d64d555
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions apache-jena/bin/tdbloader2common
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,28 @@ function getFreeMem() {
darwin*)
# Have to get this from top
FREE_MEM=$(top -l 1 | grep PhysMem | awk '{print $6}')
FREE_MEM=${FREE_MEM%M}
FREE_MEM=$(($FREE_MEM * 1024 * 1024))
MEM_UNIT=${FREE_MEM:${#FREE_MEM}-1:1}
FREE_MEM=${FREE_MEM%${MEM_UNIT}}
case "${MEM_UNIT}" in
K)
# Unlikely but let's cover our bases
FREE_MEM=$((${FREE_MEM} * 1024))
;;
M)
FREE_MEM=$((${FREE_MEM} * 1024 * 1024))
;;
G)
FREE_MEM=$((${FREE_MEM} * 1024 * 1024 * 1024))
;;
T)
# Probably a ways off but let's be future proof
FREE_MEM=$((${FREE_MEM} * 1024 * 1024 * 1024 * 1024))
;;
*)
# Unable to determine
FREE_MEM=-1
;;
esac
;;
linux*)
# Try to use free if available
Expand Down

0 comments on commit d64d555

Please sign in to comment.