Most of the time you may get ‘OutOfMemoryError’ when you run Tomcat application. This is because your default tomcat heap size is small or it is not enough for your web applications.
To set the java heap size, follow the below steps:
– Stop Tomcat server
– run the following command
export CATALINA_OPTS=”-Xms256m -Xmx512m”
or
export JAVA_OPTS=”-Xms256m -Xmx512m”
– Start Tomcat
You can also use the above variables in your Tomcat startup scripts:
Check the file Tomcat-Home/bin/catalina.sh or catalina.bat , and then restart the Tomcat server
set CATALINA_OPTS=-Xms256m -Xmx512m (For Windows, no “” around the value)
export CATALINA_OPTS=-Xms256m -Xmx512m (For ksh/bash, “” around the value)
setenv CATALINA_OPTS=-Xms256m -Xmx512m (For tcsh/csh, “” around the value)


