I am using SBT 0.12.0. I have read other answers on stack overflow and followed them, however none of them helps, for example:
ForkRun
clas
On windows, for sbt 0.13.9.2, you need to set JAVA_OPTS
to the jvm options you want.
> set JAVA_OPTS=-Xmx1G
> sbt assembly
The sbt.bat
script loads its defaults from conf\sbtconfig.txt
into CFG_OPTS
but will use JAVA_OPTS
instead if set.
Relevant excerpts from sbt.bat
:
rem FIRST we load the config file of extra options.
set FN=%SBT_HOME%\..\conf\sbtconfig.txt
set CFG_OPTS=
FOR /F "tokens=* eol=# usebackq delims=" %%i IN ("%FN%") DO (
set DO_NOT_REUSE_ME=%%i
rem ZOMG (Part #2) WE use !! here to delay the expansion of
rem CFG_OPTS, otherwise it remains "" for this loop.
set CFG_OPTS=!CFG_OPTS! !DO_NOT_REUSE_ME!
)
. . . (skip) . . .
rem We use the value of the JAVA_OPTS environment variable if defined, rather than the config.
set _JAVA_OPTS=%JAVA_OPTS%
if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS%
:run
"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%sbt-launch.jar" xsbt.boot.Boot %*
As of March 2015, if you are using sbt on OSX with Homebrew then you should edit the file /usr/local/etc/sbtopts
e.g.
# set memory options
#
#-mem <integer>
-mem 2048
I have found the solution. No matter how you specify JVM heap size, it will never work because SBT executable already has it overridden.
There is a line in SBT executable which says:
. /usr/share/sbt/sbt-launch-lib.bash
So I edited the file:
# run sbt
execRunner "$java_cmd" \
${SBT_OPTS:-$default_sbt_opts} \
- $(get_mem_opts $sbt_mem) \
${java_opts} \
${java_args[@]} \
-jar "$sbt_jar" \
"${sbt_commands[@]}" \
"${residual_args[@]}"
Remove the -
line.
Now when you run SBT, it will no longer override your JVM heap size settings. You can specify heap size settings using @Noan's answer.
Or alternatively:
sbt -J-Xmx4G -J-Xms4G
A quick way to do it is with a .jvmopts
file in the root of your project (from the Lagom Framework documentation):
$ cat .jvmopts
-Xms512M
-Xmx4096M
-Xss2M
-XX:MaxMetaspaceSize=1024M