6

How can I increase the compilation memory for the project in the build.sbt? Not in the general SBT config.

I want the config to be committed into my Git repo.

Cheers

Joan
  • 4,079
  • 2
  • 28
  • 37
  • Check out http://stackoverflow.com/questions/3868863/how-to-specify-jvm-maximum-heap-size-xmx-for-running-an-application-with-run – mfirry Sep 03 '15 at 14:03
  • This applies to running the app with more memory. I am looking to COMPILE with more memory. – Joan Sep 03 '15 at 14:04
  • I don't think so. Unless you specify `javaOptions in run += "-Xmx8G"` (so with `in run`). Give it a try. – mfirry Sep 03 '15 at 14:13
  • That didn't work even with `fork := true` – Joan Sep 03 '15 at 14:25
  • the stackoverflow solution linked above is a java VM runtime solution and not a compiler "scalac" solution. It also does not apply to the modern Scala 11 and 12 versions that use SBT to build (which is the context of the original posters "how do I do this in build.sbt" requirement) – Andrew Norman Apr 18 '18 at 21:01
  • "javaoptions in run is also a VM not a javac compiler" solution. – Andrew Norman Apr 18 '18 at 21:05
  • the suggested solution is to do this: – Andrew Norman Apr 18 '18 at 21:05

2 Answers2

4

Create .sbtopts file in root of your SBT project and put in -J-Xmx4G (and similarly -J<JVM option>. Unfortunately, it doesn't seem to work on Windows.

Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
0

the apparent solution would be to do it this way:

scalacOptions in ThisBuild ++= Seq ("-JXss512m","-JXmx2G")

while I see these values display when I run: sbt show scalacOptions

the settings do not seem to be honored by the actual compiler

Andrew Norman
  • 843
  • 9
  • 22