简体   繁体   English

sbt, "java.lang.OutOfMemoryError: Java 堆空间"

[英]sbt, "java.lang.OutOfMemoryError: Java heap space"

I'm trying to replicate the openie4.0 program by: https://github.com/knowitall/openie我正在尝试通过以下方式复制 openie4.0 程序: https://github.com/knowitall/openie

The environment is Ubuntu: 18.04, Scala: 2.10.2, Java: 1.7.0_80, sbt: 0.13.18,环境是Ubuntu:18.04,Scala:2.10.2,Java:1.7.0_80,sbt:0.13.18,

I managed to get to the step of "running with sbt:" ''' sbt 'run-main edu.knowitall.openie.OpenIECli' '''我设法进入了“使用 sbt 运行:” ''' sbt 'run-main edu.knowitall.openie.OpenIECli' '''

However, I kept facing with the problem of但是,我一直面临着问题

java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space

when I step into to create the stand-alone jar, when using:当我进入创建单机jar时,使用时:

sbt clean compile assembly

while trying "sbt -J-Xmx2700M clean compile assembly" (or larger, say 10g, I have 64g on my computer) The above out of memeory problem continues plus:在尝试“sbt -J-Xmx2700M clean compile assembly”时(或更大,比如 10g,我的电脑上有 64g)上面的内存不足问题继续加上:

java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
[error] Not a valid command: J-Xmx10g
[error] Not a valid project ID: J-Xmx10g
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: J-Xmx10g
[error] J-Xmx10g
[error]     

This is super confusing why this command isn't a valid one and I didn't find a solution for this.这非常令人困惑,为什么这个命令不是一个有效的命令,而且我没有找到解决方案。

Later on I tried to set the universal JAVA_OPTS, not working.后来我尝试设置通用的 JAVA_OPTS,但没有用。 Then I take the suggestions from user972946 (last one), which suggest its overriden since the default settings.然后我接受了 user972946(最后一个)的建议,这表明它自默认设置以来就被覆盖了。 How to set heap size for sbt? 如何设置 sbt 的堆大小? . .

Then trying after fixing as he suggested,but still the same.....然后按照他的建议修复后尝试,但还是一样.....

env JAVA_OPTS="-Xmx41200m" sbt clean compile assembly

I also took the suggestion from Mike and Cassio from the above link...not working at all.我还从上面的链接中接受了 Mike 和 Cassio 的建议……根本不起作用。

Really appreciate on any suggestions on this.非常感谢对此的任何建议。

Many thanks.非常感谢。 HZ赫兹

According to Baeldung:根据Baeldung 的说法:

Try exporting this environment variable before running it:在运行之前尝试导出此环境变量:

export SBT_OPTS="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=10G -Xmx10G -Xms10G"

Alternatively, SBT allows us to specify the JVM options on a file named .jvmopts .或者, SBT 允许我们在名为.jvmopts的文件上指定 JVM 选项。 create a file called .jvmopts in the root of your project and put this inside:在项目的根目录中创建一个名为.jvmopts的文件并将其放入:

-Xms1g
-Xmx4g

If you take a look at the following line:如果您查看以下行:

[error] Not a valid command: J-Xmx10g

Your sbt cannot resolve this as a valid option, this can be issued since you're using java 7 (make sure java7 accepts -Xmx$size as a valid argument), the same thing goes for sbt 0.13 (which is pretty old).您的 sbt 无法将此解析为有效选项,因为您使用的是 java 7(确保 java7 接受-Xmx$size作为有效参数),所以可以发出此选项,sbt 0.13(非常旧)也是如此。 there also must be a file or something related to deployments (a guide or a CI/CD file or something) that you can take help from on how to run the project.还必须有一个文件或与部署相关的东西(指南或 CI/CD 文件或其他东西),您可以从中获得有关如何运行项目的帮助。 (if you use java 8 everything should be fine probably) (如果你使用 java 8 应该没问题)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM