Novell Home

NetWare 6.0 Web Infrastructure Part 3: Increasing the Amount of RAM that Tomcat Can Use

Novell Cool Solutions: Feature
By Joe Harmon

Digg This - Slashdot This

Posted: 18 Feb 2003
 

Joe Harmon is part of Novell's Web Services Support team. This material is adapted from some excellent training sessions he recently presented here at Novell. He graciously allowed us to share it with you in this series of articles.

NEW: Click here for a PDF of the entire series.

Here is how to increase the amount of RAM that Tomcat can use.

(1) Open your TOMCAT33.NCF file found in the SYS:/TOMCAT/33/BIN directory. Here we will need to add two parameters to the file. One for the minimum heap size and one for the maximum heap size. The parameters are as follows:

-Xms128m -Xmx256m

(2) Now we will insert these parameters into the TOMCAT33.NCF file. At the bottom of the file you will find the following line:

java -envCWD=$TOMCAT_HOME -classpath $TOMCAT_CLASSPATH -Dtomcat.home=SYS:\tomcat\33 org.apache.tomcat.startup.Main -f sys:/tomcat/33/conf/nwserver.xml %1

(3) We will add the heap size parameters to this line, right after the "java" directive. The new line will look as follows.

java -Xms128m -Xmx256m -envCWD=$TOMCAT_HOME -classpath $TOMCAT_CLASSPATH -Dtomcat.home=SYS:\tomcat\33 org.apache.tomcat.startup.Main -f sys:/tomcat/33/conf/nwserver.xml %1

Important: Each java process is allocated 512 meg of user space within the RAM that it can use. Some of that is used for java threads, socket communication, etc. So what is really available is not much more than 400 meg which can be allocated to a java process. This information can be seen at the server by typing in the command JAVA -SHOW and then finding out what the ID is for the Tomcat java process. Then at the server console you can type JAVA -SHOWMEMORY# with the # representing the Tomcat process ID. Then switch over to the logger screen and you should see how much memory is being allocated within the Tomcat process. An example is shown below:

JAVA -SHOW

Classname                                                                   ID
================================   =========
org.apache.tomcat.startup.main.................................. 390

JAVA -SHOWMEMORY390

Memory Statistics For Class: org.apache.tomcat.startup.Main
-------------------------------------------------------------------------------------------
Reserved Heap: 68161536
Committed Heap: 11124732
Reserved Virtual Memory Pool: 67108864
Committed Virtual Memory Pool: 11272192
NLM Data Memory: 225280
Per Thread Data And OS Stacks: 3403776
Virtual Memory Pool Overflow: 0
JVM Tracking Memory: 23381
Socket Communication Memory: 101616
-------------------------------------------------------------------------------------------
Total Committed Virtual Memory: 22622204
Total Physical Memory: 3528773
Total Committed JVM Memory: 26150977

Note: The main statistics to look at here are the reserved heap and the committed heap. The reserved heap represents our -Xmx switch. This is the maximum memory that is allocated to the individual java process. What we show here by default is 68161536 which equates to 65 meg. The committed heap represents the -Xms switch. This is the minimum amount of memory that will be committed to the individual java process. In this instance we have 11124732 which equated to 8 meg of committed memory.

(4) To verify that our switches have changed our committed and reserved heap sizes, we will need to take down java and then restart tomcat. See example below:

JAVA -EXIT

Important: If the console comes back with MODULE JAVA.NLM UNLOADED, then you can startup tomcat by typing in TOMCAT33 at the console prompts. If it comes back that it is still cleaning up resources in the background, and you have a console prompt, then you can type in JAVA -EXIT again to force java down.

(5) Once tomcat is started again then you can check the memory again and it should now show up.

Memory Statistics For Class: org.apache.tomcat.startup.Main
-----------------------------------------------------------------------------------------------
Reserved Heap: 272633856
Committed Heap: 136314876

Troubleshooting: If you do not show the new memory size then one of the following probably happened.
(A) You reloaded Tomcat before JAVA was completely unloaded.
(B) You specified a maximum heap (-Xmx) that was too large. The most that this can be is around -Xmx386m without addition configuration.
(C) Your -Xms parameter is larger than your -Xmx parameter.

On NetWare 6 we have the option of loading the AUTOEXEC.BAT file with a -u switch to increase the amount of memory that can be used by the JVM. This switch can be used in conjunction with java heap parameters to utilize dedicate more memory to memory intensive Web Applications. Examples of memory intensive Web application on NetWare 6 are Novell Portal Services 1.5 and eGuide 2.0.

There are a few things that should be noted before using the -u parameter. The -u parameter allows you to specify a higher amount of memory than exists on your server. This could create problems if you are trying to specify memory that you don't have. So what should be done to avoid this? Well, don't exceed the amount of RAM that you have on your server with the -u parameter. In fact it would be well advised for you to not go above three quarters of the amount of RAM that you have. Remember that the JVM is not the only application on the server that will be using the RAM. Take care to leave some RAM available for other processes.

(6) Edit the AUTOEXEC.BAT file found at the root of the C:\ drive. It should look similar to the example below:

C:
CD \NWSERVER
SERVER

(7) After editing the file to add the -u switch, it should look similar to the example below, with the exception that the number value may be different depending on the desired amount of RAM needed for the JAVA process.

C:
CD \NWSERVER
SERVER -u1000000000

Note: In this example we are specifying 1 GIG of RAM to be used. The parameter is measured in bytes. This will get past the limit specified in step (4). You should now be able to increase your heap size above 400 MB.

In this Series

NEW: Click here for a PDF of the entire series.


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell