Permalink to this page: https://cwiki.apache.org/confluence/x/iSklBg

Preface

This page discusses various memory issues. In a nutshell - if your computer has less than 128MB of ram - you will probably have trouble. Anyhow, also read the following threads for other memory related issues:

JSP Recompilation

If your application uses JSPs which are frequently recompiled at runtime, e.g. headers that change value hourly, please make sure to read the JSP HOW-TO page and RELEASE NOTES documents. You may wish to tune the JSP compiler configuration to prevent memory leaks. Of course, these are documents you should have read by now anyways..

Questions

How do I adjust memory settings?

First look at java -X to determine what parameters to set. Then you can set them via the environment variable CATALINA_OPTS. Read a comment at the top of the files catalina.bat or catalina.sh for more information on CATALINA_OPTS.

Note that there also exists environment variable JAVA_OPTS, but it should not be used to set the memory settings. The difference is that JAVA_OPTS settings are used for all Tomcat management commands. When you stop Apache Tomcat (using shutdown.sh or catalina.sh stop command), a small short-lived Java process is created that notifies the main Java process of Tomcat that it has to shut down. This small Java process does not need the same memory settings as the main process. The small process uses the settings from JAVA_OPTS. The main process uses the settings from both JAVA_OPTS and CATALINA_OPTS.

If you launch Tomcat in any other way that does not use catalina.bat or catalina.sh to prepare a command line for Java (e.g. you launch java directly from within an IDE, or you use a Service Wrapper to run Tomcat as a service on Windows), see their options on how to provide settings for the java executable. E.g. Apache Commons Daemon service wrapper for Windows has a GUI configuration dialog that can be opened by running tomcat9w.exe or a similar command.

Why do I get OutOfMemoryError errors?

Many reasons.

How much memory is Tomcat/webapp/??? using?