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
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
#!/bin/sh
test -f ~/.sbtconfig && . ~/.sbtconfig
exec java -Xmx512M ${SBT_OPTS} -jar /usr/local/Cellar/sbt/0.12.3/libexec/sbt-launch.jar "$@"
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
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")
Reference: https://www.scala-sbt.org/sbt-native-packager/archetypes/java_app/customize.html
You need SBT_OPTS, here's what I use in my .bash_profile:
export SBT_OPTS="-Xmx1536M -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=2G -Xss2M -Duser.timezone=GMT"
UPDATE: To get your 2G heap space you can use this:
export SBT_OPTS="-Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=2G -Xss2M -Duser.timezone=GMT"
NOTE: SBT MUST BE LATEST VERSION
Older versions of sbt contain bugs that override these settings, use brew upgrade sbt for latest sbt for Mac (assuming brew install) (IDK for Linux). https://github.com/sbt/sbt/issues/2945#issuecomment-277490848
If running sbt from PowerShell, set the SBT_OPTs environment variable, like so:
$env:SBT_OPTS="-Xms512M -Xmx1024M -Xss2M -XX:MaxMetaspaceSize=1024M"
Then run:
sbt
"sbt -mem 23000 run" works for me.