Author: scooter
Date: 2011-06-24 17:25:33 -0700 (Fri, 24 Jun 2011)
New Revision: 25937

Added:
   cytoscape/trunk/distribution/src/main/bin/gen_vmoptions.bat
   cytoscape/trunk/distribution/src/main/bin/gen_vmoptions.sh
Modified:
   cytoscape/trunk/distribution/src/main/bin/cytoscape.bat
   cytoscape/trunk/distribution/src/main/bin/cytoscape.sh
Log:
Added back ability to calculate the amount of physical memory and use
that for java startup options


Modified: cytoscape/trunk/distribution/src/main/bin/cytoscape.bat
===================================================================
--- cytoscape/trunk/distribution/src/main/bin/cytoscape.bat     2011-06-25 
00:06:38 UTC (rev 25936)
+++ cytoscape/trunk/distribution/src/main/bin/cytoscape.bat     2011-06-25 
00:25:33 UTC (rev 25937)
@@ -5,6 +5,19 @@
 
 @echo off
 
+:: Create the Cytoscape.vmoptions file, if it doesn't exist.
+IF EXIST "Cytoscape.vmoptions" GOTO vmoptionsFileExists
+CALL gen_vmoptions.bat
+:vmoptionsFileExists
+
+IF EXIST "Cytoscape.vmoptions" GOTO itIsThere
+; Run with defaults:
+echo "*** Missing Cytoscape.vmoptions, falling back to using defaults!"
+java -Dswing.aatext=true -Dawt.useSystemAAFontSettings=lcd -Xss10M -Xmx768M 
-jar cytoscape.jar -p plugins %*
+GOTO end
+
+:: We end up here if we have a Cytoscape.vmoptions file:
+:itIsThere
 :: Read vmoptions, one per line.
 setLocal EnableDelayedExpansion
 for /f "tokens=* delims= " %%a in (Cytoscape.vmoptions) do (

Modified: cytoscape/trunk/distribution/src/main/bin/cytoscape.sh
===================================================================
--- cytoscape/trunk/distribution/src/main/bin/cytoscape.sh      2011-06-25 
00:06:38 UTC (rev 25936)
+++ cytoscape/trunk/distribution/src/main/bin/cytoscape.sh      2011-06-25 
00:25:33 UTC (rev 25937)
@@ -9,10 +9,14 @@
        script_path="$(readlink $script_path)"
 fi
 
-
 #vm_options_path=$HOME/.cytoscape
 vm_options_path=$script_path
 
+# Attempt to generate Cytoscape.vmoptions if it doesn't exist!
+if [ ! -e "$vm_options_path/Cytoscape.vmoptions"  -a  -x 
"$script_path/gen_vmoptions.sh" ]; then
+    "$script_path/gen_vmoptions.sh"
+fi
+
 if [ -r $vm_options_path/Cytoscape.vmoptions ]; then
     java `cat "$vm_options_path/Cytoscape.vmoptions"` -jar 
"$script_path/cytoscape.jar" -p "$script_path/plugins" "$@"
 else # Just use sensible defaults.

Added: cytoscape/trunk/distribution/src/main/bin/gen_vmoptions.bat
===================================================================
--- cytoscape/trunk/distribution/src/main/bin/gen_vmoptions.bat                 
        (rev 0)
+++ cytoscape/trunk/distribution/src/main/bin/gen_vmoptions.bat 2011-06-25 
00:25:33 UTC (rev 25937)
@@ -0,0 +1,56 @@
+@echo off
+
+:: Generates the Cytoscape.vmoptions file based on whether
+:: we're dealing with a 32 bit or 64 bit JVM.
+
+:: Create the .cytoscape directory if it doesn't already exist
+;if exist "%HOMEPATH%\.cytoscape" goto dot_cytoscape_exists
+;mkdir "%HOMEPATH%\.cytoscape"
+;:dot_cytoscape_exists
+
+set physmem=768
+set mem=768
+if exist findmem.out del findmem.out
+systeminfo | find "Total Physical Memory" > findmem.out
+if %ERRORLEVEL% NEQ 0 GOTO Javatest
+for /f "tokens=4" %%i in (findmem.out) do set physmem=%%i
+set physmem=%physmem:,=%
+
+if %physmem% GTR 1536 set mem=1024
+if %physmem% GTR 2048 set mem=1536
+if %physmem% GTR 3072 set /a mem=%physmem%-1024
+REM if %physmem% GTR 4096 set mem=3072
+REM if %physmem% GTR 9216 set mem=4096
+
+:Javatest
+       if exist findstr.out del findstr.out
+       java -version 2>&1 | findstr /I 64-Bit > findstr.out
+       if %ERRORLEVEL% NEQ 0 GOTO Nojava
+       for /f %%i in ('dir /b findstr.out') do if %%~zi equ 0 goto 32bit
+
+:64bit
+       REM echo "64 bit %mem% MB"
+       echo -Xms20m > Cytoscape.vmoptions
+       echo -Xmx%mem%m  >>Cytoscape.vmoptions
+       echo -Xss10m >>Cytoscape.vmoptions
+       goto Shared
+
+:32bit
+       REM echo "32 bit %mem% MB"
+       REM Some java versions can only support 1400MB
+       if %mem% GTR 1400 set mem=1400
+       echo -Xms10m   > Cytoscape.vmoptions
+       echo -Xmx%mem%m >>Cytoscape.vmoptions
+       echo -Xss10m   >>Cytoscape.vmoptions
+
+:Shared
+       echo -Dswing.aatext=true               >>Cytoscape.vmoptions
+       echo -Dawt.useSystemAAFontSettings=lcd >>Cytoscape.vmoptions
+       goto End
+
+:Nojava
+       echo ERROR: Can't find java executable
+
+:End
+       del findstr.out
+       del findmem.out

Added: cytoscape/trunk/distribution/src/main/bin/gen_vmoptions.sh
===================================================================
--- cytoscape/trunk/distribution/src/main/bin/gen_vmoptions.sh                  
        (rev 0)
+++ cytoscape/trunk/distribution/src/main/bin/gen_vmoptions.sh  2011-06-25 
00:25:33 UTC (rev 25937)
@@ -0,0 +1,52 @@
+#!/bin/sh
+# Generates the Cytoscape.vmoptions file
+
+script_path="$(dirname -- $0)"
+
+#vm_options_path="$HOME/.cytoscape"
+vm_options_path=$script_path
+
+if [ ! -e $vm_options_path ]; then
+    /bin/mkdir $vm_options_path
+fi
+
+# Determine amount of physical memory present:
+if [ `uname` = "Darwin" ]; then
+    phys_mem=`sysctl -a | grep 'hw.memsize =' | sed 's/[ ][ ][ ]*/ /g' | cut 
-f 3 -d ' '`
+    phys_mem=$((phys_mem / 1024 / 1024)) # Convert from B to MiB
+else # We assume Linux
+    phys_mem=`cat /proc/meminfo | grep 'MemTotal:' | sed 's/[ ][ ][ ]*/ /g' | 
cut -f 2 -d ' '`
+    phys_mem=$((phys_mem / 1024)) # Convert from KiB to MiB
+fi
+
+# Now we know the amount of physical memory, but we don't want to try to use 
it all
+mem=768
+if [ $phys_mem -gt 3071 ]; then 
+    mem=$((phys_mem-1024))
+elif [ $phys_mem -gt 2047 ]; then 
+    mem=1536
+elif [ $phys_mem -gt 1535 ]; then 
+    mem=1024
+fi
+
+if `java -version 2>&1 | grep -- 64-Bit > /dev/null`; then # We have a 64 bit 
JVM.
+    echo -Xms20m          >  "$vm_options_path/Cytoscape.vmoptions"
+    echo -Xmx${mem}m      >> "$vm_options_path/Cytoscape.vmoptions"
+    echo -Xss10m          >> "$vm_options_path/Cytoscape.vmoptions"
+    echo -d64             >> "$vm_options_path/Cytoscape.vmoptions"
+else # Assume a 32 bit JVM.
+    # Truncate memory setting at 1550 MiB:
+    if [ $mem -gt 1550 ]; then
+        mem=1550
+    fi
+
+    echo -Xms10m          >  "$vm_options_path/Cytoscape.vmoptions"
+    echo -Xmx${mem}m      >> "$vm_options_path/Cytoscape.vmoptions"
+    echo -Xss10m          >> "$vm_options_path/Cytoscape.vmoptions"
+fi
+
+# Shared JVM options
+echo -Dswing.aatext=true               >> 
"$vm_options_path/Cytoscape.vmoptions"
+echo -Dawt.useSystemAAFontSettings=lcd >> 
"$vm_options_path/Cytoscape.vmoptions"
+
+exit 0


Property changes on: cytoscape/trunk/distribution/src/main/bin/gen_vmoptions.sh
___________________________________________________________________
Added: svn:executable
   + *

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to