Skip to content

Commit

Permalink
FreeBSD, SunOS - Corrected total memory size
Browse files Browse the repository at this point in the history
  • Loading branch information
ktgw0316 committed Mar 23, 2014
1 parent bb05ac2 commit 60528be
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
17 changes: 15 additions & 2 deletions linux/products/lightzone
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@ echo Starting LightZone version 4.1.0 beta6 ...
echo with options : ${@}

arch=`getconf LONG_BIT`
totalmem=`cat /proc/meminfo | grep MemTotal | sed -r 's/.* ([0-9]+) .*/\1/'`
PLATFORM=`uname`
if [ "${PLATFORM}" = "Linux" ]; then
totalmem=`cat /proc/meminfo | grep 'MemTotal: ' | sed -r 's/.* ([0-9]+) .*/\1/'`
sharedir=/opt/lightzone
elif [ "${PLATFORM}" = "SunOS" ]; then
totalmem=`prtconf | grep 'Memory size:' | sed -r 's/.* ([0-9]+) .*/\1/'`
totalmem=`expr $totalmem \* 1024`
sharedir=/opt/lightzone
elif [ "${PLATFORM}" = "FreeBSD" ]; then
totalmem=`dmesg | grep 'real memory' | sed -r 's/.* ([0-9]+) .*/\1/'`
totalmem=`expr $totalmem / 1024`
sharedir=/usr/local/share/java/lightzone
fi

if [ $totalmem -ge 1024000 ]; then
maxmem=$(( $totalmem / 2 ))
# on 32-bit architectures there is ~2GB limit for maximum Java heap size
Expand All @@ -17,4 +30,4 @@ else
maxmem=512000
fi

(cd "/opt/lightzone" && LD_PRELOAD="$lzmalibrary" LD_LIBRARY_PATH="/opt/lightzone" exec java -Xmx${maxmem}k -Djava.library.path="/opt/lightzone" -Dfile.encoding=UTF8 -classpath "/opt/lightzone/*" com.lightcrafts.platform.linux.LinuxLauncher ${@} )
(cd $sharedir && LD_LIBRARY_PATH=$sharedir exec java -Xmx${maxmem}k -Djava.library.path=$sharedir -Dfile.encoding=UTF8 -classpath "$sharedir/*" com.lightcrafts.platform.linux.LinuxLauncher ${@} )
1 change: 1 addition & 0 deletions linux/scripts/findmaxmem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ elif [ "${PLATFORM}" = "SunOS" ]; then
totalmem=`expr $totalmem \* 1024`
elif [ "${PLATFORM}" = "FreeBSD" ]; then
totalmem=`dmesg | grep 'real memory' | sed -r 's/.* ([0-9]+) .*/\1/'`
totalmem=`expr $totalmem / 1024`
fi
echo $totalmem

Expand Down
6 changes: 4 additions & 2 deletions linux/src/com/lightcrafts/platform/linux/LinuxPlatform.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ public int getPhysicalMemoryInMB() {
if (matcher.matches()) {
String text = matcher.replaceAll("$1");
int i = Integer.parseInt(text);
if (osname.indexOf("SunOS") >= 0)
if (osname.indexOf("Linux") >= 0)
return i / 1024;
else if (osname.indexOf("SunOS") >= 0)
return i;
else
return i / 1024;
return i / 1048576;
}
line = buffer.readLine();
}
Expand Down

0 comments on commit 60528be

Please sign in to comment.