Hey Ede,

I updated oj_linux.sh so that it uses up to 80% of available RAM on Linux
instead of defaulting to 512M.

Tested with 32 and 64 bit JVM (only allows max 3GB on 32 bit JVM).
Tested on Mac OSX - doesn't do anything, but doesn't break the script
either.

Patch is attached.   I don't have write access to the OJ repo.  Can you
apply the patch or give me write access and I'll apply it myself?


Thanks......     lreeder
Index: oj_linux.sh
===================================================================
--- oj_linux.sh	(revision 3878)
+++ oj_linux.sh	(working copy)
@@ -17,11 +17,11 @@
 ## to overwrite OS default locale setting
 #JAVA_LANG="-Duser.language=de -Duser.country=DE"
 
+
 ## set some defaults (as macosx.command uses this script, it might define other defaults)
 MAIN="com.vividsolutions.jump.workbench.JUMPWorkbench"
 JAVA_SAXDRIVER=${JAVA_SAXDRIVER-org.apache.xerces.parsers.SAXParser}
 JAVA_LOOKANDFEEL=${JAVA_LOOKANDFEEL-javax.swing.plaf.metal.MetalLookAndFeel}
-JAVA_MAXMEM=${JAVA_MAXMEM--Xmx512M}
 
 ## end function, delays closing of terminal
 end(){
@@ -53,6 +53,26 @@
   postinstall "$1"
 }
 
+setmaxmem() {
+DEFAULTMEMMB=512M
+
+#For linux, determine 80% total ram
+if [ "Linux" = `uname` ]; then
+  MEMTOTAL=`cat /proc/meminfo | grep MemTotal | sed 's/MemTotal: *//' | sed 's/ kB//'`
+  #calculate 80% RAM (in mebibytes, since meminfo is in kibibytes)
+  DEFAULTMEMMB=`expr $MEMTOTAL \* 80 / 100 / 1000`
+  $JAVA -d64 -version > /dev/null 2>&1
+  IS64BIT=$?
+
+  #limit 32-bit Linux to 3GB ram
+  if [ "$IS64BIT" -eq "1" -a "$DEFAULTMEMMB" -gt "3000" ]; then
+     DEFAULTMEMMB="3000M"
+  else
+     DEFAULTMEMMB="$DEFAULTMEMMB"M
+  fi
+fi
+}
+
 ## detect home folder
 if(test -L "$0") then
   auxlink=`ls -l "$0" | sed 's/^[^>]*-> //g'`
@@ -113,6 +133,11 @@
  echo "Couldn't find java in your PATH ($PATH). Please install java or 
 add the location of java to your PATH environment variable." && ERROR=1 && end
 
+setmaxmem
+
+#if no overrides, use calculated default
+JAVA_MAXMEM=${JAVA_MAXMEM--Xmx$DEFAULTMEMMB}
+
 # resolve recursive links to java binary
 relPath(){ echo $1 | awk '/^\//{exit 1}'; }
 relPath "$JAVA" && JAVA="$(pwd)/$JAVA"
@@ -222,4 +247,4 @@
 cd "$OLD_DIR"
 
 ## run end function
-end
\ No newline at end of file
+end
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to