Why am I getting OutOfMemoryError compilation error in Scala?

半世苍凉 提交于 2019-12-22 10:44:36

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/5191359/why-am-i-getting-outofmemoryerror-compilation-error-in-scala

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