我拥有Play 2.2.X应用程序。
我使用Specs2运行了一套规格,最终导致关于permgen空间的内存不足。
然后我将此设置放在我的Build.scala
:
sbt.Keys.fork in Test := false
现在它就像一个魅力。
根据一些文档,Play 2.X forks默认测试以防止内存泄漏,但我确实观察到了相反的情况。
在分叉测试时观察permgen问题的原因是什么?我只是不明白。
更新-------------- 使用此配置:
parallelExecution in Test := false,
javaOptions in (Test,run) ++= Seq("-Xms512M", "-Xmx2048M", "-XX:MaxPermSize=2048M", "-XX:+CMSClassUnloadingEnabled")
这是我在启用分叉时获得的错误:
Uncaught exception when running htmlreporting.AllSpecs: java.lang.OutOfMemoryError: PermGen space
sbt.ForkMain$ForkError: PermGen space
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at scala.collection.parallel.immutable.LazyParVectorCombiner.result(ParVector.scala:129)
at scala.collection.parallel.immutable.LazyParVectorCombiner.result(ParVector.scala:105)
at scala.collection.Parallelizable$class.par(Parallelizable.scala:42)
at scala.collection.AbstractTraversable.par(Traversable.scala:105)
at org.specs2.reporter.AllExporting$$anonfun$export$1$$anonfun$2.apply(AllExporting.scala:28)
at org.specs2.reporter.AllExporting$$anonfun$export$1$$anonfun$2.apply(AllExporting.scala:27)
at scalaz.syntax.IdOps$class.$bar$greater(IdOps.scala:15)
at scalaz.syntax.ToIdOps$$anon$1.$bar$greater(IdOps.scala:82)
at org.specs2.reporter.AllExporting$$anonfun$export$1.apply(AllExporting.scala:32)
at org.specs2.reporter.AllExporting$$anonfun$export$1.apply(AllExporting.scala:24)
at scalaz.syntax.IdOps$class.$bar$greater(IdOps.scala:15)
at scalaz.syntax.ToIdOps$$anon$1.$bar$greater(IdOps.scala:82)
at org.specs2.reporter.AllExporting$class.report(AllExporting.scala:17)
at org.specs2.reporter.SbtConsoleReporter.report(SbtReporter.scala:20)
at org.specs2.runner.SbtRunner.org$specs2$runner$SbtRunner$$specificationRun(SbtRunner.scala:75)
at org.specs2.runner.SbtRunner$$anonfun$newTask$1$$anon$5.execute(SbtRunner.scala:59)
at sbt.ForkMain$Run.runTest(ForkMain.java:239)
at sbt.ForkMain$Run.runTestSafe(ForkMain.java:211)
at sbt.ForkMain$Run.runTests(ForkMain.java:187)
at sbt.ForkMain$Run.run(ForkMain.java:251)
当我的conf变为:
时效果很好 parallelExecution in Test := false,
sbt.Keys.fork in Test := false, //here's the important setting
javaOptions in (Test,run) ++= Seq("-Xms512M", "-Xmx2048M", "-XX:MaxPermSize=2048M", "-XX:+CMSClassUnloadingEnabled")
答案 0 :(得分:1)
我替换了这个设置:
javaOptions in (Test,run) ++= Seq("-Xms512M", "-Xmx2048M", "-XX:MaxPermSize=2048M", "-XX:+CMSClassUnloadingEnabled"),
由此:
javaOptions ++= Seq("-Xms512M", "-Xmx2048M", "-XX:MaxPermSize=2048M", "-XX:+CMSClassUnloadingEnabled"), //without (Test,run) and it works
它现在有效!
为什么?...是否有另一个特定的群组而不是Test
和Run
?