cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject svn commit: r997486 - /cassandra/trunk/conf/cassandra-env.sh
Date Wed, 15 Sep 2010 20:36:58 GMT
Author: brandonwilliams
Date: Wed Sep 15 20:36:58 2010
New Revision: 997486

URL: http://svn.apache.org/viewvc?rev=997486&view=rev
Log:
make adaptive heap size calculation portable.  Patch by Peter Schuller, reviewed by brandonwilliams
for CASSANDRA-1507

Modified:
    cassandra/trunk/conf/cassandra-env.sh

Modified: cassandra/trunk/conf/cassandra-env.sh
URL: http://svn.apache.org/viewvc/cassandra/trunk/conf/cassandra-env.sh?rev=997486&r1=997485&r2=997486&view=diff
==============================================================================
--- cassandra/trunk/conf/cassandra-env.sh (original)
+++ cassandra/trunk/conf/cassandra-env.sh Wed Sep 15 20:36:58 2010
@@ -16,8 +16,22 @@
 
 calculate_heap_size()
 {
-    system_memory=`free -m | awk '/Mem:/ {print $2}'`
-    MAX_HEAP_SIZE=$((system_memory / 2))M
+    case "`uname`" in
+        Linux)
+            system_memory_in_mb=`free -m | awk '/Mem:/ {print $2}'`
+            MAX_HEAP_SIZE=$((system_memory_in_mb / 2))M
+            return 0
+        ;;
+        FreeBSD)
+            system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'`
+            MAX_HEAP_SIZE=$((system_memory_in_bytes / 1024 / 1024 / 2))M
+            return 0
+        ;;
+        *)
+            MAX_HEAP_SIZE=1024M
+            return 1
+        ;;
+    esac
 }
 
 # The amount of memory to allocate to the JVM at startup, you almost
@@ -26,8 +40,11 @@ calculate_heap_size()
 # MAX_HEAP_SIZE="4G"
 
 if [ "x$MAX_HEAP_SIZE" = "x" ]; then
-    calculate_heap_size
-    echo "Using adaptive heap size: " $MAX_HEAP_SIZE
+    if calculate_heap_size; then
+        echo "Using adaptive heap size: " $MAX_HEAP_SIZE
+    else
+        echo "Using default heap size: " $MAX_HEAP_SIZE
+    fi
 fi
 
 # Specifies the default port over which Cassandra will be available for



Mime
View raw message