Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
For 2023 - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Increasing Java Virtual Machine memory for Tomcat

Q. "How do I increase the memory that my Java Virtual Machine in Tomcat can use?" A question asked - not for the first time - by a delegate on todays's Deploying Apache httpd and Tomcat course.

A. Set the JAVA_OPTS environment variable. Longer answer:

If you're running on a Unix or Linux system, edit the setenv.sh file in Tomcat's bin directory to add in a line like:
export JAVA_OPTS="-Xms128m -Xmx512m"
or on a Windows system, add in to setenv.bat something like:
set JAVA_OPTS=-Xms128 -Xmx512
and restart the Tomcat server.

By default (out of the tar), Tomcat starts up with just 64 Mbytes allocated to the JVM, and that's also it's maximum. This is a very low figure, but it's a sensible default for a new install where the person setting the system up isn't into the tuning of the system.

The two extra parameters specified via JAVA_OPTS are as follows:
-Xms - the amount of memory that the JVM starts with.
-Xmx - the maximum memory that the JVM may have.
I have seen advise (but have no proof) that your should keep the -Xms figure rather lower than the -Xmx figure, since Tomcat uses more memory at startup than when it's running. The result (if you have them set to the same value) is a peak and unnecessary memory demand at startup which in an extreme case can cause a failure.

A couple of other tips:

a) You should consider using the -server option too to run your JVM in server rather than (default) client mode (actually, they're two different but related VMs). The server that's selected with -server is slower to load but is said to run faster.

b) We have customers who run multiple instances of Tomcat on the same box (but on different ports) - not a bad idea if you're sharing load between multiple processors. You can front them with httpd using mod-proxy-balance or mod-jk to distribute the requests, but at the same time to provide "sticky sessions" so that a series of requests made by an individual user will all be handled by the same instance.
(written 2008-07-24, updated 2008-07-25)

Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
A912 - Web Application Deployment - Upgrading and tuning Tomcat
  [1377] Load Balancing with Apache mod_jk (httpd/Tomcat) - (2007-10-02)
  [1908] Java CLASSPATH explained - (2008-11-26)
  [2060] Database connection Pooling, SSL, and command line deployment - httpd and Tomcat - (2009-03-01)
  [2082] Jmeter - a first test case - (2009-03-14)
  [3018] Tuning Apache httpd and Tomcat to work well together - (2010-10-27)

A901 - Replaced Page
  [1370] Apache Tomcat Performance Tuning - (2007-09-29)
  [2079] Java - Memory Allocation and garbage collection - (2009-03-14)
  [2272] Monitoring and loading tools for testing Apache Tomcat - (2009-07-07)

A692 - Web Application Deployment - Monitoring and load testing your server
  [2080] Using ApacheBench and jconsole to test and monitor Tomcat - (2009-03-14)
  [3015] Logging the performance of the Apache httpd web server - (2010-10-25)
  [3019] Apache httpd Server Status - monitoring your server - (2010-10-28)
  [3027] Server logs - drawing a graph of gathered data - (2010-11-03)

A656 - Web Application Deployment - More Tomcat Configuration
  [282] Short weekend - (2005-04-17)
  [466] Separating 'per instance' data from binaries and web sites - (2005-10-16)
  [1899] Virtual Hosting under Tomcat - an example - (2008-11-22)

A506 - Web Application Deployment - Java - Installing and Deploying optional Technologies
  [2081] Connecting jconsole remotely - the principles - (2009-03-14)
  [3043] Gathering information - logging - with log4j. First steps. - (2010-11-12)

Back to
Q - Should I use Perl or Python?
Previous and next
Horse's mouth home
Forward to
A special day - last Friday in July
Some other Articles
PHP examples - source code and try it out too
Perl 6 - When will we have a production release?
Some Ruby lesser used functions
A special day - last Friday in July
Increasing Java Virtual Machine memory for Tomcat
Q - Should I use Perl or Python?
Larger applications in PHP
Pictures from South Hampshire
Hillier Gardens, Hampshire
Ways to accept credit cards - or not!
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page

This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2023: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/1718_Inc ... omcat.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb