Apache Tomcat is widely used Web Container in the world. Very big companies run on Apache Tomcat now a days. There are quite a few other alternatives like IBM WebSphere, Geronimo, IIS, etc. but Tomcat is my favorite one too.
It’s very critical for us to configure all correct parameters while running your application in Production environment or even in development env.
In this tutorial we will go over steps on how to configure
-Xms, -Xmx and -XX:PermSize value for Tomcat server. Let’s first understand few terms.
Specifies the maximum size, in
bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter
k or K to indicate kilobytes, or
m or M to indicate megabytes. The default value is 64MB. The upper limit for this value will be approximately 4000m on Solaris 7 and Solaris 8 SPARC platforms and
2000m on Solaris 2.6 and x86 platforms, minus overhead amounts. So, in simple words, you are saying Java to use Maximum of 1024 MB from available memory.
NOTE: there is
NO SPACE between -Xmx and 1024m
It’s a size of the heap for the young generation.
It’s used to set size for Permanent Generation. It is where class files are kept.
Another must read: Change -Xmx value of Tomcat in Eclipse IDE
Let’s get started:
Below are the simple steps to change -Xmx / -Xms values or other JVM parameters if you are running Tomcat from
Download Apache Tomcat.
Go to Apache Tomcat
By default you wont see
setenv.sh (for Linux/Mac) or
setenv.bat (for windows) file under
/bin directory. You have to create one with below parameters.
export CATALINA_OPTS="$CATALINA_OPTS -Xms512m"
export CATALINA_OPTS="$CATALINA_OPTS -Xmx8192m"
export CATALINA_OPTS="$CATALINA_OPTS -XX:MaxPermSize=256m"
- Go to command prompt.
- Go to
- Execute command:
Monitor logfile and you should see your Tomcat started with all your specified parameters in
PS: For Windows environment you need to create
setenv.bat file and run Tomcat with
Join the Discussion
Share & leave us some comments on what you think about this topic or if you like to add something.