PermGen error with tomcat server in Eclipse

I was running a tomcat web application using Maven in Eclipse.  Halfway during the process it was throwing a PermGen error.

To solve this I stopped the server in Eclipse.  Double clicked on the server in the Servers tab to open the Overview page for the server.  Clicked on Open Launch Configuration and then on the Arguments tab.  I added the following VM arguments :  -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

Clicked on OK and relaunched the server.  This worked at first and then started to happen again.  I looded into it further: (quoting from

To understand this error message and fix it, we have to remember that, for optimized, more efficient garbage-collecting Java Heap is managed in generations.

The permanent generation holds meta-data describing user classes (classes that are not part of the Java language). Examples of such meta-data are objects describing
classes and methods and they are stored in the Permanent Generation. Applications with large code-base can quickly fill up this segment of the heap which will cause java.lang.OutOfMemoryError: PermGen no matter how high your -Xmx and how much memory you have on the machine. Sun JVMs allow you to resize the different generations of the heap, including the permanent generation. On a Sun JVM (1.3.1 and above) you can configure the initial permanent generation size and the maximum permanent generation size.

To set a new initial size on Sun JVM use the -XX:PermSize=64m option when starting the virtual machine. To set the maximum permanent generation size use -XX:MaxPermSize=128m option. If you set the initial size and maximum size to equal values you may be able to avoid some full garbage collections that may occur if/when the permanent generation needs to be resized.

One Comment to “PermGen error with tomcat server in Eclipse”

  1. The arguments for setting Heap space are
    -Xmx for maximum heap size, and
    -Xms for initial heap size

    eg -Xms256m -Xmx1g

Leave a Reply