I am trying to build a Scala project on IntelliJ using Gradle. I am able to make but compile keeps failing with a stack overflow error.
I looked through other posts with similar issues which suggested increasing heap/stack size (this and this). So far I have tried setting these in JAVA_OPTS and idea64.exe.vmoptions.
-Xss512m -Xms512m -Xmx2048m -XX:ReservedCodeCacheSize=64m -ea
I also tried including -XX:MaxPermSize=2048m which didn't work either (believe it is not supported in Java 8 anyway).
The same code builds for another person with the same configuration. Can anyone please shed some light on what I am missing?
Details:
IntelliJ Ultimate 2016.1
Scala 2.10.3
Java 1.8.0_92
Stack Trace:
java.lang.StackOverflowError
at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:696)
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$96.apply(Typers.scala:4523)
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$96.apply(Typers.scala:4523)
at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:680)
at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4522)
at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4578)
at scala.tools.nsc.typechecker.Typers$Typer.typedInAnyMode$1(Typers.scala:5343)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5360)
at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:696)
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:5472)
at scala.tools.nsc.typechecker.Typers$Typer.typedQualifier(Typers.scala:5480)
at scala.tools.nsc.transform.Erasure$Eraser.adaptMember(Erasure.scala:642)
at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:696)
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5396)
at scala.tools.nsc.typechecker.Typers$Typer.scala$tools$nsc$typechecker$Typers$Typer$$typedInternal(Typers.scala:5423)
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5370)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5374)
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$96.apply(Typers.scala:4523)
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$96.apply(Typers.scala:4523)
at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:680)
at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4522)
at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4578)
StackOverflowError is an error which Java doesn't allow to catch, for instance, stack running out of space, as it's one of the most common runtime errors one can encounter.
StackOverflowError is a runtime error which points to serious problems that cannot be caught by an application. The java. lang. StackOverflowError indicates that the application stack is exhausted and is usually caused by deep or infinite recursion.
In most cases your project JDK is not compatible with Scala or sbt version, try to change the Scala Compile Server SDK. Press Ctrl+Alt+S to open Settings/Preferences dialog. From the options on the left, select Build, Execution, Deployment | Compiler | Scala | Scala Compiler Server.
The exception is from the compiler that IntelliJ employs, hence you need to change the compiler build process' heap size. Go to
File -> Settings -> Build, Execution, Deployment -> Compiler -> Build process
heap size (Mbytes)
Increase this property to a higher value.
I've solved this via:
Preferences -> Build, Execution, Deployment -> Compiler -> Scala Compiler -> Scala Compile Server
And updated JVM options to use a bigger stack size, eg: -Xss8m
Restart for the changes to take effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With