Solving Tomcat outofmemoryerror: heap space and permgen spacetomcat March 12th, 2009
It's quite common to run inMemory problemsWhen running some big Java EE application on a Tomcat server.
Some of the most commmon errors are like the following ones.
This is about a fullHeap Space:
Severe: servlet. Service () for servlet JSP threw exceptionjava. Lang. outofmemoryerror: Java heap Space
This other is aboutPermgen SpaceThat's a memory area, where compiled classes (andJSPs
) Are kept, and this error might happen often if the running web application have happens. Java and. jsp.
Memoryerror: permgen spacejava. Lang. outofmemoryerror: permgen Space
To increase the memory available to Tomcat, aboutHeapAndPermgenThe correct options are the following ones.
This sets the maxHeapAvailable to Tomcat at 1 GB of memory:
-- Jvmmx 1024
This sets the maxPermgenAvailable to Tomcat at 256 MB of memory:
-XX: maxpermsize = 256 m
To change the Tomcat memory settings (when Tomcat is installed on WindowsSystem Service), It's required to use the command-line toolTomcat6
. The next command changes the memory settings for the Tomcat service namedTomcat6
Tomcat6 // us // tomcat6 -- jvmmx 1024 + + jvmoptions = "-XX: maxpermsize = 256 m"
The label// Us // tomcat6
Has the meaningUPdatingSErver parameters for the service namedTomcat6.
Obviusly this command shocould be executed from the directoryC:/program files/Apache Software Foundation/tomcat 6.0/bin
Or from wherever isBin
Directory of your tomcat installation. Or to make things simple, that directoy shocould be added to yourPath
Environment variable.
It's even possible to update memory settings from a GUI frontend, or to view what happened after running the command line tool. Running the following command:
Tomcat6w // es // tomcat6
A window will open showing all the parameters about the Windows ServiceTomcat6.
It's possible to see in this image that, after running the previous command, for setting higher memory limits, in the sectionsMaximum Memory PoolAnd at the end ofJava optionsThe new memory limits are set.
Tomcat memory settings on Windows