Thursday, October 22, 2009

Java PermGen Space Out of Memory Error Using Tomcat as a Service

Many people experience an out of memory error using Java with Tomcat.

Tomcat defaults the memory that is reserved for Java to --JvmMs 128 --JvmMx 256.

If you receive an out of memory error, then you need to adjust these values.

If you are using Tomcat as a service, you need to change these parameters in the service.bat file. In the version Tomcat 5.527, locate this line in the service.bat file: --JvmMs 128 --JvmMx 256. You can change these values to increase the Java Heap Space in Tomcat.

You will need to uninstall the service, and reinstall it to make these values take effect. After you have changed these values and reinstalled the service, open up your tomcat5w.exe located in your bin directory, and you should see the size of your heap space set to the values you inputted in your service.bat file.

Changing the values directly in the Tomcat5w.exe file didn't seem to work for this version of Tomcat without changing it in the service.bat file and reinstalling the service.

However, if you are using Tomcat 5.0.28, changing the Initial memory pool and Maximum memory pool in the Tomcat5w.exe and restarting the service does work. (You do not have to change it in the service.bat file and reinstall the service)

0 comments: