简体   繁体   English

Scala编译期间出现内存不足错误

[英]Out of memory error during Scala compilation

I'm using the macro-heavy scala-pickling along with shapeless , and I keep crashing the Scala 2.10.3 compiler with an apparent out of memory error. 我正在使用大量的scala-picklingshapeless ,并且我一直使Scala 2.10.3编译器崩溃,并出现明显的内存不足错误。 The tail of the error message looks like this: 错误消息的结尾看起来像这样:

[error]     <tpt> // tree.tpe=tasks.anonfun$218
[error]     Block( // tree.tpe=Unit
[error]       Apply( // def <init>(): scala.runtime.AbstractFunction1 in class AbstractFunction1, tree.tpe=scala.runtime.AbstractFunction1
[error]         SimpleMiddlebury$$anonfun$218.super."<init>" // def <init>(): scala.runtime.AbstractFunction1 in class AbstractFunction1, tree.tpe=()scala.runtime.AbstractFunction1
[error]         Nil
[error]       )
[error]       ()
[error]     )
[error]   )
[error] )
[error] 
[error] == Expanded type of tree ==
[error] 
[error] ConstantType(value = Constant(anon$326))
[error] 
[error] uncaught exception during compilation: java.io.IOException
[error] Cannot allocate memory

I'm monitoring my system memory, and there's plenty, so if this is really a problem with memory allocation, I'm guessing there's some JVM flag I can set somewhere to make the problem go away. 我正在监视我的系统内存,并且有很多内存,因此,如果这确实是内存分配问题,我猜我可以在某个地方设置一些JVM标志以使问题消失。

However, I have tried increasing the available memory, by adjusting the heap setting in paulp's sbt script to -Xmx8g , and I still get this error. 不过,我尝试增加可用内存,通过调整堆设置paulp的SBT脚本-Xmx8g ,我仍然得到这个错误。 Is this the right flag? 这是正确的标志吗?

Ideas? 想法?

EDIT: I added the "scala-pickling" and "shapeless" tags, because this is something other users of those libraries may have encountered. 编辑:我添加了“ scala-pickling”和“ shapeless”标签,因为这是那些库的其他用户可能遇到的东西。

in your sbt installation directory lives a file ./bin/sbt sbt安装目录中的文件为./bin/sbt

update the -Xss settings in this file to a higher threshold. 将此文件中的-Xss设置更新为更高的阈值。 Setting it to -Xss8M was enough for my shapeless stack overflow compilation issues to go away 将其设置为-Xss8M足以解决我无形的堆栈溢出编译问题

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

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