Increase memory in sbt-assembly

3.4k views Asked by At

Is there a way to increase the memory during assembly (the plugin)? I notice that adding more memory to sbt through SBT_OPTS does't really help. I suspect that assembly is forking a separate JVM that doesn't inherit the JVM configurations from sbt.

Here is the error:

java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space

Here is what I tried without much luck:

javaOptions in assembly += "-Xmx2g"

4

There are 4 answers

6
Eugene Yokota On BEST ANSWER

I suspect that assembly is forking a separate JVM that doesn't inherit the JVM configurations from sbt.

I'm the author of sbt-assembly. assembly does not fork a separate JVM. You can see the code here and check - https://github.com/sbt/sbt-assembly/blob/0.13.0/src/main/scala/sbtassembly/Assembly.scala#L239-L246

0
Amarjeet Singh On

You can increase heap size by using below mentioned command in linux environment:-

sbt -J-Xms2048m -J-Xmx2048m assembly
0
Mariusz On

Make sure to export SBT_OPTS. Mine is "-Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=2G -Xss2M"

0
Ken Zhu On

I met the same issue before, Please do it as below for windows. The issue could be gone.

set SBT_OPTS="-Xmx2G"
sbt assembly