mercredi 26 juin 2013

How do I increase the permgen size of Tomcat Server ?





  • Increase the Heap size from the catalina.sh file



Tomcat production server sometime will hit the following java.lang.OutOfMemoryError: PermGen space error.


java.lang.OutOfMemoryError: PermGen space
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)

you should increase the memory by make change in catalina.sh.

Cataline.sh is located at \tomcat folder\bin\catalina.sh
Assign following line to JAVA_OPTS variable and add it into catalina.sh file.
export CATALINA_OPTS="-Xms512m -Xmx1024m"
JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 
-server -Xms2536m -Xmx2536m
-XX:NewSize=256m -XX:MaxNewSize=1024m -XX:PermSize=1536m 
-XX:MaxPermSize=1536m -XX:+DisableExplicitGC"

  • Increase the Heap size from the the Eclipse IDE


if you are using tomcat sever with eclipse you need to resolve this exception by modifying the tomcat arguments :
If you see java.lang.OutOfMemoryError: PermGen space errors, you need to increase the permanent generation space available to Eclipse.
PermGen is the permanent generation of objects in the VM (Class names, internalized strings, objects that will never get garbage-collected). An easy, if somewhat memory-hungry fix is to enlarge the maximum space for these objects by adding


  • double click on the tomcat server
  • Click to Open Launch Configuration

  • Choose the Arguments tab and add the following parameters
     -Xms1024m -Xmx1024m -XX:PermSize=1024m -XX:MaxPermSize=1024m





  • Be Careful !!!!
you have to be careful when increasing the heap size of your tomcat server and jvm.


 As you can see, if you allocate a large Java Heap (2 GB+) for a 32-bit JVM process, the native memory space capacity will be reduced automatically, opening the door for JVM native memory allocation failures.
you will get the following exception :OutOfMemoryError: unable to create new native thread


For a 64-bit JVM process, your main concern, from a JVM C-Heap perspective, is the capacity and availability of the OS physical, virtual and swap memory.
 What you will learn shortly is that this JVM problem is very often related to native memory depletion; either at the JVM process or OS level. For now please keep in mind that:



  • A 32-bit JVM process is in theory allowed to grow up to 4 GB (even much lower on some older 32-bit Windows versions).
  • For a 32-bit JVM process, the C-Heap is in a race with the Java Heap and PermGen space e.g. C-Heap capacity = 2-4 GB – Java Heap size (-Xms, -Xmx) – PermGen size (-XX:MaxPermSize)
  • A 64-bit JVM process is in theory allowed to use most of the OS virtual memory available or up to 16 EB (16 million TB)






Aucun commentaire:

Enregistrer un commentaire