尝试通过sbt构建项目时,Docker中的GC开销限制已超出

时间:2015-07-15 19:26:04

标签: scala garbage-collection docker sbt boot2docker

我正在尝试在 docker 容器中构建 sbt 项目并收到此类错误:

  

java.lang.OutOfMemoryError:超出GC开销限制

系统规格:

  • OS osx + boot2docker(8 gig RAM for virtual machine)
  • ubuntu 15.10在docker container里面
  • Oracle java 1.7或Oracle java 1.8或OpenJdk 1.8
  • Scala版本2.11.6
  • sbt version 0.13.8

如果我运行 docker 构建w / Dockerfile ,则失败。如果我通过登录到容器手动执行它,它会构建没有异常的项目。

OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=1G; support was removed in 8.0
sbt appears to be exiting abnormally.
The log file for this session is at /tmp/sbt4972348477806548245.log
java.lang.OutOfMemoryError: GC overhead limit exceeded
    at java.io.UnixFileSystem.resolve(UnixFileSystem.java:108)
    at java.io.File.<init>(File.java:262)
    at java.io.File.listFiles(File.java:1290)
    at sbt.FilterFiles.handleFile(Path.scala:192)
    at sbt.DescendantOrSelfPathFinder.sbt$DescendantOrSelfPathFinder$$handleFileDescendant(Path.scala:204)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:206)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:205)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108)
    at sbt.DescendantOrSelfPathFinder.sbt$DescendantOrSelfPathFinder$$handleFileDescendant(Path.scala:205)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:206)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:205)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108)
    at sbt.DescendantOrSelfPathFinder.sbt$DescendantOrSelfPathFinder$$handleFileDescendant(Path.scala:205)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:206)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:205)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108)
    at sbt.DescendantOrSelfPathFinder.sbt$DescendantOrSelfPathFinder$$handleFileDescendant(Path.scala:205)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:206)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:205)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108)
    at sbt.DescendantOrSelfPathFinder.sbt$DescendantOrSelfPathFinder$$handleFileDescendant(Path.scala:205)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:206)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:205)
    at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
    at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:108)
    at sbt.DescendantOrSelfPathFinder.sbt$DescendantOrSelfPathFinder$$handleFileDescendant(Path.scala:205)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:206)
    at sbt.DescendantOrSelfPathFinder$$anonfun$sbt$DescendantOrSelfPathFinder$$handleFileDescendant$1.apply(Path.scala:205)
Error during sbt execution: java.lang.OutOfMemoryError: GC overhead limit exceeded
2015/07/15 21:59:19 The command '/bin/sh -c /web/tools/bin/sbt compile' returned a non-zero code: 1

非常感谢您的帮助!! 1

1 个答案:

答案 0 :(得分:1)

问题出在sbt设置USER someuser,然后在此用户下运行sbt clean。解决方案是运行sbt clean w / next命令RUN runuser -l someuser -c 'sbt clean

是:

USER someuser
sbt clean

成为:

runuser -l someuser -c 'sbt clean'