简体   繁体   English

IntelliJ 上 Scala 的 StackOverflowError

[英]StackOverflowError with Scala on IntelliJ

I am trying to build a Scala project on IntelliJ using Gradle.我正在尝试使用 Gradle 在 IntelliJ 上构建一个 Scala 项目。 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 ).我查看了其他有类似问题的帖子,这些帖子建议增加堆/堆栈大小( thisthis )。 So far I have tried setting these in JAVA_OPTS and idea64.exe.vmoptions.到目前为止,我已经尝试在 JAVA_OPTS 和 idea64.exe.vmoptions 中设置这些。

-Xss512m -Xms512m -Xmx2048m -XX:ReservedCodeCacheSize=64m -ea -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).我也试过包括 -XX:MaxPermSize=2048m 这也不起作用(相信它在 Java 8 中不受支持)。

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)

The exception is from the compiler that IntelliJ employs, hence you need to change the compiler build process' heap size.例外来自 IntelliJ 使用的编译器,因此您需要更改编译器构建过程的堆大小。 Go to

File -> Settings -> Build, Execution, Deployment -> Compiler -> Build process 
heap size (Mbytes)

Increase this property to a higher value.将此属性增加到更高的值。

屏幕截图显示设置窗格将值增加到 1024 MB

I've solved this via:我已经通过以下方式解决了这个问题:

Preferences -> Build, Execution, Deployment -> Compiler -> Scala Compiler -> Scala Compile Server首选项 -> 构建、执行、部署 -> 编译器 -> Scala 编译器 -> Scala 编译服务器

And updated JVM options to use a bigger stack size, eg: -Xss8m并更新了 JVM 选项以使用更大的堆栈大小,例如: -Xss8m

Restart for the changes to take effect.重新启动以使更改生效。

在 eclipse.ini 中添加 -Xss100m 在我的情况下有效,可能在 intellijJ 中添加类似的属性可能会有所帮助。

Here is what worked for me:这是对我有用的:

  • From Windows Powershell, $env:SBT_OPTS="-Xss1024m" and then ran sbt compile从 Windows Powershell, $env:SBT_OPTS="-Xss1024m" 然后运行 ​​sbt compile

  • Also in IntelliJ v2020.2, following also worked: Settings -> Build, Execution, Deployment -> Build Tools -> SBT -> JVM : VM Parameters : -Xss1024m同样在 IntelliJ v2020.2 中,以下也有效:设置 -> 构建、执行、部署 -> 构建工具 -> SBT -> JVM:VM 参数:-Xss1024m

I had same issues and done lots changes in intellij but non of them work.我遇到了同样的问题并在 intellij 中做了很多更改,但没有一个工作正常。

I removed unused case classes from my code and its working我从我的代码及其工作中删除了unused case classes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM