How To: Allocating more memory for Java and Tomcat
Summary
To avoid java.lang.OutOfMemory errors, increase the value of -Xmx512M
Issue
I 'm getting java.lang.OutOfMemory errors
Applies to
Adobe Graphics Server
Adobe Document Server
Solution
The problem is that by default, the Java Virtual Machine and Tomcat (WebServices) only use a small amount of memory. You can adjust the RAM they will use with the -Xmx option as in -Xmx1000M. (Meaning use up to 1000MB if available.)
When using the WebServices from the Java command line, you must use the -Xmx option twice. Once to increase the RAM available to Tomcat (WebServices), and second for the Java command line.
Determining how much RAM is needed
If you're working with images that are roughly 4000 x 4000 pixels and one layer, try -Xmx1000M as a starting point.
- Run your commands against your largest file and watch the memory usage of the Java processes.
On Windows: use the "Processes" tab of the "Windows Task Manager"
On Solaris: run "prstat" in a Console window - Adjust the value of -Xmx based on the RAM requirements of your commands and your files. (convertProfile and saveOptimized use more RAM than some of the other commands.)
Assign more RAM to the Java command line examples
1. Open, for example, ResizeImage.bat or ResizeImage.sh at:
{your install location}\Samples\java\commandline\ResizeImage.bat
2. Add -Xmx1000M to the line:
set COMMAND=java -cp "%THECLASSPATH%" com.adobe.altercast.commandline.ResizeImage %*
resulting in:
set COMMAND=java -Xmx1000M -cp "%THECLASSPATH%" com.adobe.altercast.commandline.ResizeImage %*
Assign more RAM to Tomcat (WebServices) on Windows
- Open wrapper.properties at:
{your install location}\server\conf\wrapper.properties - Scroll down to the bottom and you will find:
# This is the command line that is used to start Tomcat. You can *add* extra
# parameters to it but you can not remove anything.
# wrapper.cmd_line="$(wrapper.javabin)" -Xrs -Xmx512M -classpath "$(wrapper.class_path)" $(wrapper.startup_class) -config "$(wrapper.server_xml)" -home "$(AlterCastTomcatHome)" - Modify the value of: -Xmx512M
- Restart the AlterCastDocEdition service or the AlterCastImageEdition service in the Services control panel.
- Open in a text editor tomcat.sh at {your install location}/server/bin/tomcat.sh
- Find the line reading: TOMCAT_OPTS=" -Xmx512M" and modify whatever number is currently there
- Restart Tomcat using:
shutdown.sh and then startup.sh
1 comment:
###############
Set Tomcat Java memory heap size
###############
when you are using tomcat as you application server for not small application you can easy get (out of memory exception). this is because the default heap size tomcat use is small and suitable only for small web applications.
to set the start and maximum heap size run the following command before starting your tomcat:
export CATALINA_OPTS=”-Xms256m -Xmx512m”
or
export JAVA_OPTS=”-Xms256m -Xmx512m”
this will create environment variable called CATALINA_OPTS or JAVA_OPTS contains the required options to make tomcat start heap size 256M and maximum heap size 512M.
Post a Comment