and yes before you mark this as duplicate I've already read
How to prevent java.lang.OutOfMemoryError: PermGen space?
and
How to prevent java.lang.OutOfMemoryError: PermGen space at Scala compilation?
But it does not provide any solution to me.
Here is the Problem
I do have a simple test in my application written with junit like:
public class FooTest extends BaseTest {
@Test
public void testSomeMethod() {
...
//Some Asserts
...
}
}
I am trying to run this test with Intellij by simple click on "Run":
The following configuration is then created:
Running the test prints then following:
[IJ][pos] $ all {file:/C:/somepath/test/}pos/foopackage {file:/C:/somepath/test/}pos/test:foopackage
[info] Compiling 1 Scala source and 6 Java sources to C:\somepath\test\target\scala-2.11\classes...
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at sbt.ConcurrentRestrictions$$anon$4.take(ConcurrentRestrictions.scala:188)
at sbt.Execute.next$1(Execute.scala:83)
at sbt.Execute.processAll(Execute.scala:86)
at sbt.Execute.runKeep(Execute.scala:66)
at sbt.EvaluateTask$.liftedTree1$1(EvaluateTask.scala:359)
at sbt.EvaluateTask$.run$1(EvaluateTask.scala:358)
at sbt.EvaluateTask$.runTask(EvaluateTask.scala:378)
at sbt.Aggregation$$anonfun$3.apply(Aggregation.scala:64)
at sbt.Aggregation$$anonfun$3.apply(Aggregation.scala:62)
at sbt.EvaluateTask$.withStreams(EvaluateTask.scala:314)
at sbt.Aggregation$.timedRun(Aggregation.scala:62)
at sbt.Aggregation$.runTasks(Aggregation.scala:71)
at sbt.Aggregation$$anonfun$applyTasks$1.apply(Aggregation.scala:32)
at sbt.Aggregation$$anonfun$applyTasks$1.apply(Aggregation.scala:31)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
at sbt.Command$$anonfun$applyEffect$2$$anonfun$apply$3.apply(Command.scala:61)
at sbt.Aggregation$$anonfun$evaluatingParser$4$$anonfun$apply$5.apply(Aggregation.scala:153)
at sbt.Aggregation$$anonfun$evaluatingParser$4$$anonfun$apply$5.apply(Aggregation.scala:152)
at sbt.Act$$anonfun$sbt$Act$$actParser0$1$$anonfun$sbt$Act$$anonfun$$evaluate$1$1$$anonfun$apply$10.apply(Act.scala:244)
at sbt.Act$$anonfun$sbt$Act$$actParser0$1$$anonfun$sbt$Act$$anonfun$$evaluate$1$1$$anonfun$apply$10.apply(Act.scala:241)
at sbt.Command$.process(Command.scala:93)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
at sbt.MainLoop$$anonfun$1$$anonfun$apply$1.apply(MainLoop.scala:98)
at sbt.State$$anon$1.process(State.scala:184)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
at sbt.MainLoop$$anonfun$1.apply(MainLoop.scala:98)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
at sbt.MainLoop$.next(MainLoop.scala:98)
at sbt.MainLoop$.run(MainLoop.scala:91)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:70)
at sbt.MainLoop$$anonfun$runWithNewLog$1.apply(MainLoop.scala:65)
at sbt.Using.apply(Using.scala:24)
at sbt.MainLoop$.runWithNewLog(MainLoop.scala:65)
at sbt.MainLoop$.runAndClearLast(MainLoop.scala:48)
at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:32)
at sbt.MainLoop$.runLogged(MainLoop.scala:24)
at sbt.StandardMain$.runManaged(Main.scala:53)
at sbt.xMain.run(Main.scala:28)
at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:109)
at xsbt.boot.Launch$.withContextLoader(Launch.scala:128)
at xsbt.boot.Launch$.run(Launch.scala:109)
at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:35)
at xsbt.boot.Launch$.launch(Launch.scala:117)
at xsbt.boot.Launch$.apply(Launch.scala:18)
at xsbt.boot.Boot$.runImpl(Boot.scala:41)
at xsbt.boot.Boot$.main(Boot.scala:17)
at xsbt.boot.Boot.main(Boot.scala)
Caused by: java.lang.OutOfMemoryError: PermGen space
[error] java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen space
[error] Use 'last' for the full log.
[IJ][pos] $
[IJ][pos] $
Here is what I tried so far:
As I mentioned Questions already posted I tried to get rid of this error by configuring the installed sbt on my system:
The version of sbt I installed is currently 0.13.15
So I configured the:
C:\installpath\Scala\sbt_0_13_15\conf\sbtconfig.txt
like below:
-Xmx2G
-Xms2G
-XX:MaxPermSize=256m
-XX:ReservedCodeCacheSize=256m
-Dsbt.log.format=false
-XX:+CMSClassUnloadingEnabled
But I still got the same error. So I checked where Intellij is getting sbt from and if the build with sbt test
from console would also fail.
sbt test
Seems to run successful:
[info] Done updating.
[info] Compiling 450 Scala sources and 1132 Java sources to C:\somepath\test\target\scala-2.11\classes
[info] Weaving 1 input to C:\somepath\test\target\scala-2.11\aspectj\classes...
[info] Compiling 103 Java sources to C:\somepath\test\target\scala-2.11\test-classes...
[info] Instrumenting 6228 classes to C:\somepath\test\target\scala-2.11\jacoco\instrumented-classes
...
[info] 2 tests, 0 failures, 0 errors
... And goes on and on
So I did check how it it configured in Intellij:
where as VM Parameters there I also typed in:
-Xmx2G -Xms2G -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=256m -Dsbt.log.format=false -XX:+CMSClassUnloadingEnabled
But still I got the same error.
Then I tried adding a .sbtopts
file into the roots folder.
The content of the file is:
-J-Xmx2G
-J-Xms2G
-J-XX:MaxPermSize=1G
-J-XX+CMSClassUnloadingEnabled
After removing
-J-XX+CMSClassUnloadingEnabled
from the .sbtopts
- File in the projects folder it was possible to build the project.
It seems that this exception cam up:
C:\Java7\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=localhost:53488,suspend=n,server=y -Xdebug -server -Xmx2G -Xms2G -XX:MaxPermSize=1G -XX+CMSClassUnloadingEnabled -Xmx2048M -Dfile.encoding=UTF-8 -Didea.runid=2017.2 -Didea.managed=true -jar C:\installpath\Scala\sbt_0_13_15\bin\sbt-launch.jar idea-shell
Unrecognized option: -XX+CMSClassUnloadingEnabled
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.