scala 执行提升项目时使用 SBT 出现内存不足错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8751936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Out of Memory Error Using SBT When Executing Lift Project
提问by Hahnemann
I am using SBT 0.7.7. When I make a change to my Lift project and re-compile via:
我正在使用 SBT 0.7.7。当我对 Lift 项目进行更改并通过以下方式重新编译时:
jetty-stopcompilejetty-run
jetty-stopcompilejetty-run
I get the following error:
我收到以下错误:
Error during sbt execution: java.lang.OutOfMemoryError: PermGen space
sbt 执行期间出错:java.lang.OutOfMemoryError: PermGen space
I have the following defined inside /opt/local/bin/sbt-0.7:
我在 /opt/local/bin/sbt-0.7 中定义了以下内容:
# Is the location of the SBT launcher JAR file.
LAUNCHJAR="/opt/local/share/sbt-0.7/sbt-launch-0.7.7.jar"
# Ensure enough heap space is created for SBT.
if [ -z "$JAVA_OPTS" ]; then
JAVA_OPTS="-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M"
fi
# Assume java is already in the shell path.
exec java $JAVA_OPTS -jar "$LAUNCHJAR" "$@"
回答by juice
The PermGen is just one of many spaces that as a whole make up the Heap. You could increase the entire heap until the portion that is allocated is big enough for your needs or you could simply increase the allocation toward the PermGen space. In order to do that latter, use
PermGen 只是构成堆的众多空间之一。您可以增加整个堆,直到分配的部分足够满足您的需要,或者您可以简单地增加对 PermGen 空间的分配。为了做到后者,请使用
For sbt 0.12.0
对于 sbt 0.12.0
export SBT_OPTS=-XX:MaxPermSize=256m
出口 SBT_OPTS=-XX:MaxPermSize=256m
It would be best to put this in your .bash_profile (assuming you are using bash)
最好将它放在您的 .bash_profile 中(假设您使用的是 bash)
For sbt 0.7
对于 sbt 0.7
In your case increase the -XX:MaxPermSize to something more than 256m. Keeping in mind that needing more than 256m suggests that there may be other issues.
在您的情况下,将 -XX:MaxPermSize 增加到 256m 以上。请记住,需要超过 256m 表明可能存在其他问题。
回答by Chewbarkla
You need to allow java to allocate more memory.
您需要允许 java 分配更多内存。
# You may need more or less depending on your project.
export SBT_OPTS=-Xmx1024M
You might revisit some of those other memory settings as well. I'm running SBT 0.11.2, and I have nothing but Xmx specified.
您也可以重新访问一些其他内存设置。我正在运行 SBT 0.11.2,除了指定的 Xmx 之外我什么都没有。
As an aside, I'd be surprised if you actually have any GC issues during a compile. Changing the GC collection strategy more relevant for longer running processes.
顺便说一句,如果您在编译期间确实遇到任何 GC 问题,我会感到惊讶。更改与运行时间更长的进程更相关的 GC 收集策略。

