I was looking to solve a problem like this on Mac OS X with a homebrew install of SBT. If you installed SBT via homebrew, you're in the clear since the /usr/local/bin/sbt file looks like
This means that any settings you put in SBT_OPTS will stick (your -Xmx will take precedence). Furthermore, the first line of the script will execute any commands in ~/.sbtconfig if it exists so it may be a better place to put your SBT options if you are playing with them quite a bit. You won't have to source ~/.bash_profile every time you make a change to SBT_OPTS
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 %*
For SBT version 1.0.4 on Windows the default JVM settings come from sbt\conf\sbtconfig.txt file. Simply edit the values here. Change -Xmx512M to -Xmx2048M.
This is not the only source of JVM options for SBT. Others can be found by inspecting sbt.bat. A simple way to diagnose, where do the settings come from, is by commenting out this line in batch file: @echo off.
In my case, the configuration of my service was overwriting the environment variable SBT_OPTS and JAVA_OPTS. I was able to set the limits by setting in my build.sbt the following:
javaOptions in Universal ++= Seq(
"-J-Xms1g",
"-J-Xmx2g")