Scala 编译期间内存不足错误 [英] Out of memory error during Scala compilation

查看:75
本文介绍了Scala 编译期间内存不足错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用宏重的 scala-picklingshapeless,并且我不断地使 Scala 2.10.3 编译器崩溃,并出现明显的内存不足错误.错误消息的尾部如下所示:

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

我正在监控我的系统内存,而且有很多,所以如果这真的是内存分配的问题,我猜我可以在某处设置一些 JVM 标志来消除问题.

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.

但是,我已经尝试通过调整 paulp 的 sbt 脚本到 -Xmx8g,但我仍然收到此错误.这是正确的标志吗?

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?

想法?

我添加了scala-pickling"和shapeless"标签,因为这些库的其他用户可能遇到过这种情况.

I added the "scala-pickling" and "shapeless" tags, because this is something other users of those libraries may have encountered.

推荐答案

在你的sbt安装目录下有一个文件./bin/sbt

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

将此文件中的 -Xss 设置更新为更高的阈值.将它设置为 -Xss8M 足以让我的无形堆栈溢出编译问题消失

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

这篇关于Scala 编译期间内存不足错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆