为什么我在 Scala 中遇到 OutOfMemoryError 编译错误?
我正在开发一个 Lift 项目,并尝试使用 scala:cc 和使用 jvm args 的 scala 编译服务器来编译它:
-Xmx1024m -Xss20m -XX:PermSize=64M -XX:MaxPermSize=512M -XX:+CMSClassUnloadingEnabled -XX:+CMSClassUnloadingEnabled
jvm args 也会出现该错误:
-Xmx1024m -Xss20m -XX:PermSize=64M -XX:MaxPermSize=512M
结果是:
[INFO] Compiling 16 source files to /Users/axaluss/IdeaProjects/trunk/Team_Skynet/target/classes at 1299141180948
[ERROR] java.lang.OutOfMemoryError: Java heap space
[INFO] at scala.tools.nsc.symtab.Types$class.typeRef(Types.scala:2503)
[INFO] at scala.tools.nsc.symtab.SymbolTable.typeRef(SymbolTable.scala:13)
[INFO] at scala.tools.nsc.symtab.Types$TypeMap.mapOver(Types.scala:2828)
[INFO] at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:3209)
[INFO] at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:3085)
[INFO] at scala.tools.nsc.symtab.Types$TypeMap.mapOver(Types.scala:2849)
[INFO] at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:3209)
[INFO] at scala.tools.nsc.symtab.Types$Type.asSeenFrom(Types.scala:507)
[INFO] at scala.tools.nsc.symtab.Types$Type.computeMemberType(Types.scala:531)
[INFO] at scala.tools.nsc.symtab.Symbols$MethodSymbol.typeAsMemberOf(Symbols.scala:1774)
[INFO] at scala.tools.nsc.symtab.Types$Type.memberType(Types.scala:522)
[INFO] at scala.tools.nsc.symtab.Types$Type.findMember(Types.scala:858)
[INFO] at scala.tools.nsc.symtab.Types$Type.nonPrivateMembers(Types.scala:453)
[INFO] at scala.tools.nsc.symtab.Types$class.lub0$1(Types.scala:4919)
[INFO] at scala.tools.nsc.symtab.Types$class.lub0$1(Types.scala:4873)
[INFO] at scala.tools.nsc.symtab.Types$class.lub(Types.scala:4943)
[INFO] at scala.tools.nsc.symtab.SymbolTable.lub(SymbolTable.scala:13)
[INFO] at scala.tools.nsc.symtab.Types$class.lubsym$1(Types.scala:4901)
[INFO] at scala.tools.nsc.symtab.Types$$anonfun$38.apply(Types.scala:4924)
[INFO] at scala.tools.nsc.symtab.Types$$anonfun$38.apply(Types.scala:4919)
[INFO] at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
[INFO] at scala.collection.immutable.List.foreach(List.scala:45)
[INFO] at scala.tools.nsc.symtab.Types$class.lub0$1(Types.scala:4919)
[INFO] at scala.tools.nsc.symtab.Types$class.lub(Types.scala:4943)
[INFO] at scala.tools.nsc.symtab.SymbolTable.lub(SymbolTable.scala:13)
[INFO] at scala.tools.nsc.symtab.Types$class.lub(Types.scala:4863)
[INFO] at scala.tools.nsc.symtab.SymbolTable.lub(SymbolTable.scala:13)
[INFO] at scala.tools.nsc.symtab.Types$class.solveOne$1(Types.scala:4675)
[INFO] at scala.tools.nsc.symtab.Types$$anonfun$solve$1.apply(Types.scala:4684)
[INFO] at scala.tools.nsc.symtab.Types$$anonfun$solve$1.apply(Types.scala:4683)
[INFO] at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
[INFO] at scala.collection.immutable.List.foreach(List.scala:45)
[ERROR] error: fatal error (server aborted): Java heap space
[ERROR] one error found
我该如何解决这个问题? 我不知道是什么导致了这个错误,除了增加内存之外,我在谷歌上找到了任何东西。
I am working on a Lift project and trying to compile it with scala:cc
and the scala compilation server using the jvm args:
-Xmx1024m -Xss20m -XX:PermSize=64M -XX:MaxPermSize=512M -XX:+CMSClassUnloadingEnabled -XX:+CMSClassUnloadingEnabled
The error also occurs with the jvm args:
-Xmx1024m -Xss20m -XX:PermSize=64M -XX:MaxPermSize=512M
The result is:
[INFO] Compiling 16 source files to /Users/axaluss/IdeaProjects/trunk/Team_Skynet/target/classes at 1299141180948
[ERROR] java.lang.OutOfMemoryError: Java heap space
[INFO] at scala.tools.nsc.symtab.Types$class.typeRef(Types.scala:2503)
[INFO] at scala.tools.nsc.symtab.SymbolTable.typeRef(SymbolTable.scala:13)
[INFO] at scala.tools.nsc.symtab.Types$TypeMap.mapOver(Types.scala:2828)
[INFO] at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:3209)
[INFO] at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:3085)
[INFO] at scala.tools.nsc.symtab.Types$TypeMap.mapOver(Types.scala:2849)
[INFO] at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply(Types.scala:3209)
[INFO] at scala.tools.nsc.symtab.Types$Type.asSeenFrom(Types.scala:507)
[INFO] at scala.tools.nsc.symtab.Types$Type.computeMemberType(Types.scala:531)
[INFO] at scala.tools.nsc.symtab.Symbols$MethodSymbol.typeAsMemberOf(Symbols.scala:1774)
[INFO] at scala.tools.nsc.symtab.Types$Type.memberType(Types.scala:522)
[INFO] at scala.tools.nsc.symtab.Types$Type.findMember(Types.scala:858)
[INFO] at scala.tools.nsc.symtab.Types$Type.nonPrivateMembers(Types.scala:453)
[INFO] at scala.tools.nsc.symtab.Types$class.lub0$1(Types.scala:4919)
[INFO] at scala.tools.nsc.symtab.Types$class.lub0$1(Types.scala:4873)
[INFO] at scala.tools.nsc.symtab.Types$class.lub(Types.scala:4943)
[INFO] at scala.tools.nsc.symtab.SymbolTable.lub(SymbolTable.scala:13)
[INFO] at scala.tools.nsc.symtab.Types$class.lubsym$1(Types.scala:4901)
[INFO] at scala.tools.nsc.symtab.Types$anonfun$38.apply(Types.scala:4924)
[INFO] at scala.tools.nsc.symtab.Types$anonfun$38.apply(Types.scala:4919)
[INFO] at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
[INFO] at scala.collection.immutable.List.foreach(List.scala:45)
[INFO] at scala.tools.nsc.symtab.Types$class.lub0$1(Types.scala:4919)
[INFO] at scala.tools.nsc.symtab.Types$class.lub(Types.scala:4943)
[INFO] at scala.tools.nsc.symtab.SymbolTable.lub(SymbolTable.scala:13)
[INFO] at scala.tools.nsc.symtab.Types$class.lub(Types.scala:4863)
[INFO] at scala.tools.nsc.symtab.SymbolTable.lub(SymbolTable.scala:13)
[INFO] at scala.tools.nsc.symtab.Types$class.solveOne$1(Types.scala:4675)
[INFO] at scala.tools.nsc.symtab.Types$anonfun$solve$1.apply(Types.scala:4684)
[INFO] at scala.tools.nsc.symtab.Types$anonfun$solve$1.apply(Types.scala:4683)
[INFO] at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:61)
[INFO] at scala.collection.immutable.List.foreach(List.scala:45)
[ERROR] error: fatal error (server aborted): Java heap space
[ERROR] one error found
How can I solve this problem?
I dont know what is causing this error and found anything on Google except increasing the memory.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然,你必须增加
mx
。 Scala 确实存在的一个问题是其巨大的内存消耗。随着 64 位 CPU 和服务器操作系统的广泛采用,以及当前 64 位桌面操作系统采用的激增,我预计它的重要性不会持续太久。Obviously, you have to increase
mx
. One problem Scala does have is its big memory consumption. With the widespread adoption of 64 bits CPUs and server OS, and the current surge in adoption of 64 bits desktop OS, I expect it won't be critical much longer.您可以从在编译器上设置一些调试开始,尝试找出其根源: http://www.scala-lang.org/docu/files/tools/scalac.html
You can start with setting some debugging on the compiler to try to find out where this stems from: http://www.scala-lang.org/docu/files/tools/scalac.html