【问题标题】:How can I specify JVM flags in a Go SBT task?如何在 Go SBT 任务中指定 JVM 标志?
【发布时间】:2015-12-11 15:18:58
【问题描述】:

我正在使用 Go CD 和 gocd-sbt-plugin 构建一个带有 SBT 的 Java+Scala 多模块项目。但是,当我尝试编译和打包模块时,内存不足 (java.lang.OutOfMemoryError: Java heap space)。

在 Jenkins CI 中,SBT 插件为我提供了在构建操作中添加 JVM 标志和 sbt 标志的选项。目前我们正在使用这些 JVM 标志:

-Xmx2G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -Xss2M

我没有在 Go 文档中找到答案,也没有尝试将上述参数放在“附加选项”文本框中。

当我尝试后者时,我得到了这个堆栈跟踪:

15:02:23.288 [info] Compiling 54 Scala sources and 3495 Java sources to /gocd/var/lib/go-agent/pipelines/de/component/build/scala-2.11/classes...
15:04:31.744 java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
15:04:31.744    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
15:04:31.744    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
... 
15:04:31.744    at xsbt.boot.Boot.main(Boot.scala)
15:04:31.744 Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
15:04:31.744    at java.util.jar.Attributes.read(Attributes.java:394)
15:04:31.744    at java.util.jar.Manifest.read(Manifest.java:199)
...
15:04:31.744    at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5373)
15:04:31.744 [error] java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
15:04:31.744 [error] Use 'last' for the full log.
15:04:31.760 [error] Expected key
15:04:31.760 [error] Expected '*'
15:04:31.760 [error] XX:+CMSClassUnloadingEnabled
15:04:31.760 [error]    ^
15:04:31.858 Error: Interaction with plugin with id 'sbt.task.plugin' implementing 'task' extension failed while requesting for 'execute'. Reason: [Unsuccessful response from plugin. Plugin returned with code '500' and the following response: '{"exception":null,"success":false,"message":"Build failure"}']
15:04:31.865 [go] Current job status: failed.

我相信该任务仍然失败,因为它没有使用这些导致 Jenkins 构建成功的标志。有人能指出我可以在哪里将上述 JVM 标志传递到我的 Go SBT 任务中吗?

【问题讨论】:

  • 我不知道你最终做了什么,但对我来说,标志 -mem 4096(例如 4 GB)在类似项目中起到了作用,在这种情况下也可能有效。例如。 sbt package -mem 4096

标签: java scala sbt jvm-arguments go-cd


【解决方案1】:

尝试通过

-J-Xmx2G
-J-Xss2M

等等。作为附加选项(请参阅https://medium.com/@jan______/sbtconfig-is-deprecated-650d6ff10236)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-19
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    • 2014-09-15
    • 2019-10-18
    • 2015-12-31
    相关资源
    最近更新 更多