Out of memory error during Scala compilation

孤者浪人 提交于 2019-12-11 05:59:20

问题


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. 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.

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. 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.


回答1:


in your sbt installation directory lives a file ./bin/sbt

update the -Xss settings in this file to a higher threshold. Setting it to -Xss8M was enough for my shapeless stack overflow compilation issues to go away



来源:https://stackoverflow.com/questions/19825809/out-of-memory-error-during-scala-compilation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!