1. Increase the maximum memory available:Tomcat ships with the maximum amount of memory set to 64MB, which is not large enough to operate most large web applications. We recommend increasing the maximum amount of memory to 80% of the total RAM available on your server. This can be done as shown below. First, open Tomcat by going to the Start Menu-Programs-Apache Tomcat-Start Tomcat.
After Tomcat has started you should see the Tomcat icon in the lower right-hand corner, as shown below.
To access the Tomcat properties allowing changes to the maximum memory, right click on the icon and select properties. This is also the way to stop the server by clicking on Shutdown: Tomcat instead of properties.
The properties screen below has the Java VM tab selected. Inside the Java Options is where we are going to add some information by going to add the increased min and max memory allocation.
The minimum value can be anything but should start with at least 64-100 MB. The maximum memory should be up to 80% of your computer's RAM. For example, if you have 512 MB of RAM, then you should set the maximum memory to around 400 MB. We are also going to add a server tag that basically tells the compiler that when it's running, it is running as a server. It changes its optimization strategy of the just-in-time compiler. To do this, you need to add this code to the Java Options text area:
Now we have changed the default memory allocation for Tomcat to handle heavier data loads. However, there are still a few more changes we can make to improve speed and efficiency.
Changes to web.xml configuration file:The web.xml is the document that defines default values for *all* Web applications loaded into each instance of Tomcat. As each application is deployed, this file is processed, followed by the "/WEB-INF/web.xml" deployment descriptor from your own applications. The web.xml is located in Apache Software Foundation-Tomcat-conf folder shown below.
Open the web.xml by right clicking and selecting open with (NotePad, Wordpad or any text editor). Now, in the document we want to find the JSP Servlet Tag. This is located a quarter of the way down the page. Add two initial parameters -- the reloading parameter and the development parameter.
The reloading and development parameters are automatically set to true when Tomcat is installed. The development init-parameter will check for JSP modification on every access and reload. Set both of these parameters in the web.xml document to false so Tomcat will not look for or reload changes to JSPs on every access.
To add the init-parameters you will add this code:
<init-param> <param-name>development</param-name> <param-value>false</param-value> </init-param> <init-param> <param-name>reloading</param-name> <param-value>false</param-name> </init-param>In summary, Tomcat is a cost-efficient tool to hosting Web applications. Now that you have made the above simple changes, Tomcat will run much faster and handle more of a data load, allowing increased performance of the development of your Web application. Tomcat also has its own administration, which can be helpful and accessed through the Tomcat Web site.
About the author: Paul Holm is a former IBM-Rochester WebSphere, Java, and DB2 developer/consultant. He specializes in helping iSeries RPG shops develop Web-based applications. Paul is currently a lead architect for the "WOW" product, which is Query/400 and DFU for WebSphere (aka WebSphere on steriods). Paul can be reached at email@example.com.
This was first published in August 2004