3

I'm trying to build Breeze by myself using Intellij IDEA

Here's my enviroment
Intellij version:2018.2.1 Community
OS:Windows 10 64-bit
JDK version:1.8.0_181
scala SDK version:2.12
sbt version: sorry.. can't find it.

At First, It kept showing the error message : java.lang.OutOfMemoryError: GC overhead limit exceeded

What I've done:
1. In "Custom VM Options", add "Xmx2048m"

2. In Settings(ctrl+alt+s)=>Build,Execution,DeployMent=>Build Tools=>sbt
change "Maximum heap size" to 9196 (really large...)

3. In Settings(ctrl+alt+s)=>Build,Execution,DeployMent=>Compiler=>Scala Compiler=>Additional compiler options, add "-J-Xmx4096m"

4. In Scala Compiler=>Scala Compile Server, change JVM maximum heap size to 4096

After doing these things, I still got a some chances to fail because out of memory during compiling.
Am I missing anything important?

LtChang
  • 135
  • 12
  • For what it's worth, I frequently get OutOfMemoryErrors when building with Scala. – Owen Oct 06 '18 at 16:41
  • how do you solve it? Can you point out which setting is important? maximum heap size? – LtChang Oct 07 '18 at 18:27
  • you should increase the maximum heap size as high as you can without thrashing. Hopefully several gigabytes (I usually find I need at least 4G for large builds). Still, even this may not be enough. In those situations, I resort to running incremental compilations multiple times. After the first one crashes, but manages to build a few files, the next one will use less memory. Not good for automated builds, but works for building while I work. – Owen Oct 07 '18 at 18:35
  • thanks, compiling many times seems to be a naive but useful solution, I was wondering why "Rebuild Module XXX" always failed and "Build Module XXX" can work sometimes – LtChang Oct 07 '18 at 18:48

1 Answers1

3

It seems you are using IntelliJ internal build system. Instead, try configuring IntelliJ to delegate building to sbt proper like so:

  1. Enable setting: Use sbt shell for build and import (required sbt 0.13.5+)

  2. Create .jvmopts file at the root of your project:

    -Xmx4G 
    -XX:MaxMetaspaceSize=4G
    
  3. In the sbt projects tool window, click sbt tasks node, and select the task you wish to run. Note, build commands from the main menu, for example,Build | Build Project, should now also be hooked into system SBT

  4. Monitor the execution output in sbt shell tool window

Mario Galic
  • 47,285
  • 6
  • 56
  • 98