I am getting this java.lang.OutOfMemoryError: PermGen space
Exception. I am using Eclipse Juno and Tomcat 7.0. This Exception occurs at least once in every 10-1
What is java.lang.OutOfMemoryError: PermGen space?
Ans:
The java.lang.OutOfMemoryError: PermGen space
message indicates that the Permanent Generation’s area in memory is exhausted.
Any Java applications is allowed to use a limited amount of memory. The exact amount of memory your particular application can use is specified during application startup.
Java memory is separated into different regions which can be seen in the following image:
What will be the solution for this error PermGen space?
Ans:
For Heap,
export JVM_ARGS="-Xms1024m -Xmx1024m"
For Permgen,
JVM_ARGS="-XX:PermSize=512M -XX:MaxPermSize=512m"
You can give also additional section
-XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC XX:+CMSClassUnloadingEnabled
You can also give more additional section :)
-XX:PermSize=512m -XX:MaxPermSize=512m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -XX:SurvivorRatio=2 -XX:MaxTenuringThreshold=128 -XX:TargetSurvivorRatio=90 -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing -XX:CMSIncrementalDutyCycleMin=0 -XX:CMSIncrementalDutyCycle=10 -XX:+UseTLAB -XX:+CMSParallelRemarkEnabled -XX:+CMSClassUnloadingEnabled
Metaspace: A new memory space is born
The JDK 8 HotSpot JVM
is now using native memory for the representation of class metadata and is called Metaspace
; similar to the Oracle JRockit
and IBM JVM's
.
The good news is that it means no more java.lang.OutOfMemoryError: PermGen space
problems and no need for you to tune and monitor this memory space anymore.
Related Link:
Java 8 Links
When you get java.lang.OutOfMemoryError: PermGen space errors
, you need to increase the permanent generation space available to Eclipse.To Do this please modify your eclipse.ini
file of Eclipse.
set the as below
-XX:MaxPermSize=1024m
For more help you can refer the below link,
java.lang.OutOfMemoryError: PermGen space
Instead making changes in eclipse.ini, its better to install Java 8.
I Installed Java 8 and now I am not getting java.lang.OutOfMemoryError: PermGen space
Exception.
It is easy to configure Java for more PermGenSpace but I would recommend to migrate to Java 1.8 runtime instead. Install Java 8 SDK and add two lines like
-vm
D:/jdk8/jre/bin/javaw.exe
to eclipse.ini. This problem is fixed starting from Java 1.8 and does not longer require any hacks.