I have a scala shell script with the following header:
#! /bin/sh
env JAVA_OPTS="-Xmx20g"
exec scala -classpath ./target/scala-2.9.1/classes:lib/* "$0" "$@"
!#
Unfortunately, no matter how I set the JAVA_OPTS variable, the program terminates with an out of memory error.
How do I properly configure heap size in such a shell script without messing with global JAVA_OPTS environment variables?
From Scala help:
Options to scala which reach the java runtime:
...
-J<arg> -J is stripped and passed to java as-is
So, you can add -J-Xmx20g
argument to scala.