2013-04-11 39 views
34

Tôi thường xuyên nhận được số OutOfMemoryError từ SBT.Làm thế nào để ngăn chặn java.lang.OutOfMemoryError: PermGen không gian?

> test 
[error] java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space 
[error] Use 'last' for the full log. 
> last 
[debug] Running task... Cancelable: false, check cycles: false 
[debug] 
[debug] Initial source changes: 
[debug]  removed:Set() 
[debug]  added: Set() 
[debug]  modified: Set() 
[debug] Removed products: Set() 
[debug] Modified external sources: Set() 
[debug] Modified binary dependencies: Set() 
[debug] Initial directly invalidated sources: Set() 
[debug] 
[debug] Sources indirectly invalidated by: 
[debug]  product: Set() 
[debug]  binary dep: Set() 
[debug]  external source: Set() 
[debug] Initially invalidated: Set() 
[debug] Copy resource mappings: 
[debug] 
[debug] 
[debug] Initial source changes: 
[debug]  removed:Set() 
[debug]  added: Set() 
[debug]  modified: Set() 
[debug] Removed products: Set() 
[debug] Modified external sources: Set() 
[debug] Modified binary dependencies: Set() 
[debug] Initial directly invalidated sources: Set() 
[debug] 
[debug] Sources indirectly invalidated by: 
[debug]  product: Set() 
[debug]  binary dep: Set() 
[debug]  external source: Set() 
[debug] Initially invalidated: Set() 
[debug] Copy resource mappings: 
[debug] 
[debug] Framework implementation 'org.scalacheck.ScalaCheckFramework' not present. 
[debug] Framework implementation 'org.specs.runner.SpecsFramework' not present. 
[debug] Framework implementation 'org.scalatest.tools.ScalaTestFramework' not present. 
[debug] Framework implementation 'com.novocode.junit.JUnitFramework' not present. 
[debug] Subclass fingerprints: Stream((org.specs2.specification.SpecificationStructure,false,[email protected]), ?) 
[debug] Annotation fingerprints: Stream() 
[debug] Running Test ExpandoObjectTest : subclass(false, org.specs2.specification.SpecificationStructure) with arguments 
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space 
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252) 
    at java.util.concurrent.FutureTask.get(FutureTask.java:111) 
    at sbt.ConcurrentRestrictions$$anon$4.take(ConcurrentRestrictions.scala:196) 
    at sbt.Execute.next$1(Execute.scala:85) 
    at sbt.Execute.processAll(Execute.scala:88) 
    at sbt.Execute.runKeep(Execute.scala:68) 
    at sbt.EvaluateTask$.run$1(EvaluateTask.scala:162) 
    at sbt.EvaluateTask$.runTask(EvaluateTask.scala:177) 
    at sbt.Aggregation$$anonfun$4.apply(Aggregation.scala:46) 
    at sbt.Aggregation$$anonfun$4.apply(Aggregation.scala:44) 
    at sbt.EvaluateTask$.withStreams(EvaluateTask.scala:137) 
    at sbt.Aggregation$.runTasksWithResult(Aggregation.scala:44) 
    at sbt.Aggregation$.runTasks(Aggregation.scala:59) 
    at sbt.Aggregation$$anonfun$applyTasks$1.apply(Aggregation.scala:31) 
    at sbt.Aggregation$$anonfun$applyTasks$1.apply(Aggregation.scala:30) 
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62) 
    at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:62) 
    at sbt.Command$.process(Command.scala:90) 
    at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(MainLoop.scala:71) 
    at sbt.MainLoop$$anonfun$next$1$$anonfun$apply$1.apply(MainLoop.scala:71) 
    at sbt.State$$anon$2.process(State.scala:170) 
    at sbt.MainLoop$$anonfun$next$1.apply(MainLoop.scala:71) 
    at sbt.MainLoop$$anonfun$next$1.apply(MainLoop.scala:71) 
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18) 
    at sbt.MainLoop$.next(MainLoop.scala:71) 
    at sbt.MainLoop$.run(MainLoop.scala:64) 
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:53) 
    at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:50) 
    at sbt.Using.apply(Using.scala:25) 
    at sbt.MainLoop$.runWithNewLog(MainLoop.scala:50) 
    at sbt.MainLoop$.runAndClearLast(MainLoop.scala:33) 
    at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:17) 
    at sbt.MainLoop$.runLogged(MainLoop.scala:13) 
    at sbt.xMain.run(Main.scala:26) 
    at xsbt.boot.Launch$.run(Launch.scala:55) 
    at xsbt.boot.Launch$$anonfun$explicit$1.apply(Launch.scala:45) 
    at xsbt.boot.Launch$.launch(Launch.scala:69) 
    at xsbt.boot.Launch$.apply(Launch.scala:16) 
    at xsbt.boot.Boot$.runImpl(Boot.scala:31) 
    at xsbt.boot.Boot$.main(Boot.scala:20) 
    at xsbt.boot.Boot.main(Boot.scala) 
Caused by: java.lang.OutOfMemoryError: 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 java.lang.ClassLoader.loadClass(ClassLoader.java:356) 
    at sbt.Project$$anon$5.apply(Project.scala:130) 
    at sbt.Project$$anon$5.apply(Project.scala:128) 
    at sbt.LogManager$.commandBase$1(LogManager.scala:59) 
    at sbt.LogManager$.command$1(LogManager.scala:60) 
    at sbt.LogManager$$anonfun$suppressedMessage$1.apply(LogManager.scala:61) 
    at sbt.LogManager$$anonfun$suppressedMessage$1.apply(LogManager.scala:61) 
    at sbt.ConsoleLogger.trace(ConsoleLogger.scala:163) 
    at sbt.AbstractLogger.log(Logger.scala:32) 
    at sbt.MultiLogger$$anonfun$dispatch$1.apply(MultiLogger.scala:40) 
    at sbt.MultiLogger$$anonfun$dispatch$1.apply(MultiLogger.scala:38) 
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59) 
    at scala.collection.immutable.List.foreach(List.scala:76) 
    at sbt.MultiLogger.dispatch(MultiLogger.scala:38) 
    at sbt.MultiLogger.trace(MultiLogger.scala:30) 
    at sbt.TestLogger$$anon$2.trace(TestReportListener.scala:71) 
    at sbt.TestLogger.endGroup(TestReportListener.scala:88) 
    at sbt.TestRunner$$anonfun$run$5.apply(TestFramework.scala:87) 
    at sbt.TestRunner$$anonfun$run$5.apply(TestFramework.scala:87) 
    at sbt.TestFramework$$anonfun$safeForeach$1.apply(TestFramework.scala:112) 
    at sbt.TestFramework$$anonfun$safeForeach$1.apply(TestFramework.scala:112) 
    at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59) 
[error] java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space 
[error] Use 'last' for the full log. 

Đôi khi nó cũng thoát ra đột ngột với:

sbt appears to be exiting abnormally. 
    The log file for this session is at /var/folders/vf/3khb58091wd0_1rz1yh6knb00000gp/T/sbt3242766352271599341.log 
java.lang.OutOfMemoryError: PermGen space 
Error during sbt execution: java.lang.OutOfMemoryError: PermGen space 

giải pháp Bất kỳ?

+0

Bạn không nói bạn đang sử dụng phiên bản SBT nào, nhưng phiên bản đầu tiên rất dễ bị chạy ra khỏi PermGen chỉ sau một vài lần tải lại định nghĩa dự án. Các phiên bản hiện tại có vẻ khá miễn dịch với vấn đề này, nhưng bạn vẫn có thể chỉ cần tăng phân bổ. –

+0

@RandallSchulz, phiên bản là 0.12.2. – missingfaktor

+0

Cũng đề cập đến phiên bản Java và hệ điều hành. – SSR

Trả lời

51

Điều này đôi khi xảy ra nếu bạn biên dịch mã lệnh lớn - rất nhiều lớp được tải vào máy chủ chạy sbt.

Bạn cần tăng không gian PermGen cho sbt - sử dụng cờ -XX:MaxPermSize=256m, trong đó 256 bạn có thể thay đổi với kích thước mong muốn của thế hệ vĩnh viễn.

Run:

cat `which sbt` 

để xác định vị trí bạn SBT kịch bản khởi động. Sau đó, chỉnh sửa nó để bao gồm cờ với lệnh java chạy trình khởi chạy sbt theo cách tương tự vì nó là described here để sửa đổi -Xmx-Xms.

Thêm cờ -XX:+CMSClassUnloadingEnabled cũng nên bật sbt để bỏ tải các trình nạp lớp với các lớp từ quá trình biên dịch trước đó không còn được sử dụng nữa.

EDIT:

Ngoài ra, bạn có thể thiết lập các tùy chọn trong biến SBT_OPTS môi trường nếu bạn đang sử dụng extended script for running sbt.

+0

Bạn cũng có thể đặt điều này bằng biến môi trường 'SBT_OPTS' không? – HeatfanJohn

+0

Tôi tin rằng điều này phụ thuộc vào kịch bản Á hậu SBT bạn đang sử dụng - nếu bạn sử dụng tập lệnh mở rộng này để chạy SBT, nó sẽ nhận các cài đặt biến SBT_OPTS và cho phép làm nhiều hơn nữa: https://github.com/paulp/sbt- extras/blob/master/sbt – axel22

+0

Điều này dường như không hoạt động đối với một số người, họ phải sử dụng SBT_OPTS. Xin vui lòng bạn có thể chỉnh sửa câu trả lời của bạn để đề cập đến điều này, nó gây ra đồng nghiệp của tôi rất nhiều đau đớn. (sau đó tôi sẽ upvote :) – samthebest

Các vấn đề liên quan