OutOfMemoryError PermGen
Introduction
OutOfMemoryError: PermGen Space
Avoiding the error
1. Increasing the PermGen Memory Size
-XX:MaxPermSize=128m
default is 64m
2. Enable Sweeping
Two remarks
1) The default permgen size is platform dependent. For example, on my Mac OS X with Java 7 I have it set at 82M:
my-machine:~ me$ java -XX:+PrintFlagsFinal -version | grep MaxPermSize
uintx MaxPermSize = 85983232 {pd product}
2) Specifying the class unloading (which is by default switched on on Java 8) only helps if the classes are no longer referenced and can be garbage collected. So it will not be something that will save you lets say from permgen leaks
You might be interested in reading the following analysis about java.lang.outofmemoryerror: Permgen space - https://plumbr.eu/outofmemoryerror/permgen-space
mvn help
$HOME/.m2/repository
). It only download what it need for the requested phases/goals (lazy downloading). So the first runs could be very long.$HOME/bin/soft-linux/jdk-1.5.0_03
)$HOME/bin/soft-java/apache-maven-2.0.8
)mvn help
, you should seeusage: mvn [options] [] [ ] Options: -q,--quiet Quiet output - only show errors ...
mvn org.apache.maven.plugins:maven-archetype-plugin:1.0-alpha-7:create \ -DarchetypeGroupId=org.scala-tools.archetypes \ -DarchetypeArtifactId=scala-archetype-simple \ -DarchetypeVersion=1.1 \ -DremoteRepositories=http://scala-tools.org/repo-releases \ -DgroupId=your.proj.gid -DartifactId=your-proj-id
... [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1 second [INFO] Finished at: Sat Jan 05 17:39:47 CET 2008 [INFO] Final Memory: 6M/63M [INFO] ------------------------------------------------------------------------
your-proj-id/ |-- pom.xml `-- src |-- main | `-- scala | `-- your | `-- proj | `-- gid | `-- App.scala `-- test `-- scala `-- your `-- proj `-- gid `-- AppTest.scala
mvn clean
# only compile mvn compile
... [ERROR] FATAL ERROR [INFO] ------------------------------------------------------------------------ [INFO] The PluginDescriptor for the plugin Plugin [org.scala-tools:maven-scala-plugin] was not found. [INFO] ...
# only compile mvn -U compile
... [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ ...
# compile + compile test + run test mvn test
... ------------------------------------------------------- T E S T S ------------------------------------------------------- Running your.proj.gid.AppTest Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.054 sec <<< FAILURE! Results : Failed tests: testKO(your.proj.gid.AppTest) Tests run: 2, Failures: 1, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [ERROR] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] There are test failures. Please refer to /home/dwayne/tmp/your-proj-id/target/surefire-reports for the individual test results.
... testKO(your.proj.gid.AppTest) Time elapsed: 0.01 sec <<< FAILURE! junit.framework.AssertionFailedError at junit.framework.Assert.fail(Assert.java:47) at junit.framework.Assert.assertTrue(Assert.java:20) at junit.framework.Assert.assertTrue(Assert.java:27) at your.proj.gid.AppTest.testKO(AppTest.scala:26) at your.proj.gid.AppTest.testKO(AppTest.scala:26) ...
# compile + run test + generate the jar mvn package
Two remarks
ReplyDelete1) The default permgen size is platform dependent. For example, on my Mac OS X with Java 7 I have it set at 82M:
my-machine:~ me$ java -XX:+PrintFlagsFinal -version | grep MaxPermSize
uintx MaxPermSize = 85983232 {pd product}
2) Specifying the class unloading (which is by default switched on on Java 8) only helps if the classes are no longer referenced and can be garbage collected. So it will not be something that will save you lets say from permgen leaks
You might be interested in reading the following analysis about java.lang.outofmemoryerror: Permgen space - https://plumbr.eu/outofmemoryerror/permgen-space
ivo
Delete1. you can set your permgen size to 82M on windows as well. i wrote default size is 64M and you can increase it upto 512M irrespective of operating system using. http://www.oracle.com/technetwork/java/javase/7u5-relnotes-1653274.html
2. you are right it will not help if classes have reference but it will be helping and ofcourse there will be classes which dont have active reference