How to Handle Out Of Memory - PermGen Space

PermGen memory is the space where the JVM stores the classes and methods data. If you start and stop tomcat a lot in a short time you can also receive this error.


A minimum of 512mb with a recommended setting of 1024mb.


This is an example of the error from the tomcat logs:

javax.servlet.ServletException: java.lang.OutOfMemoryError: PermGen space



If you have a Windows environment, the easiest way to increas space is to open the tomcat manager either through the executable in the bin directory (tomcat#w.exe - where # is the version) or from the Start menu. Here is a sample:


These settings go into the Java Options field on the Java tab. Place them after any settings that already exist.

Note: If the line -XX:MaxPermSize=1024m already exists, increase the amount of memory listed.

If you have a Linux/Unix environment you will set the CATALINA_OPTS in either the or reference it from the files.

Here is an example of settings:

CATALINA_OPTS="$CATALINA_OPTS -server -Xms256m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"