2

Yesterday I posted this question: Tomcat Excessive Memory Consumption

The thread was getting too long and detailed for anyone to continue helping. So now I am asking a more specific question.

When I run top, I get this:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
13749 tomcat6   20   0  493m  82m 9972 S    0  9.0   0:07.34 java

This is a fresh install of Tomcat6 on Ubuntu 11.04 (Nattty) (64-bit).

As I understand it, VIRT is the virtual memory. Is 493m in the VIRT column a "normal" thing, or is that excessively high? Keep in mind that there are no web apps running in Tomcat right now. It's just the basic vanilla install.

How about the 82m in the RES column? What does this mean and how does it compare to VIRT? That is the amount of memory I would expect Tomcat to use.

My hosting company is using Parallels Virtuozzo Containers, and apparently the stats I am provided with on memory usage comes somewhere from there. The stats they show me are that I am using 110% of my 512MB memory limit (burstable). So in fact they are counting 400-500MB worth of memory from Tomcat.

1
  • If you find this helpful (as some of you have mentioned), please vote up!
    – Tanner
    Aug 12, 2011 at 2:41

4 Answers 4

1

I am in the same situation as you: Virtual Server hosted with Parallels Virtuozzo Containers.

I have Debian 6 and Tomcat 7 installed, running the default apps and two additional small ones. The Tomcat 7 config is slightly changed, but still very similar to the default one:

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
29910 tomcat    18   0  525m  80m 9972 S  0.0  7.9   0:13.26 java 

So it seems quite normal. I assume you already now how to limit memory usage for Tomcat using JAVA_OPTS='-Xms256m -Xmx256m' ?

I am not sure how familiar you are with Tomcat, personally I always find this FAQ useful: http://wiki.apache.org/tomcat/HowTo http://wiki.apache.org/tomcat/HowTo#Where_and_how_do_I_set_memory_related_settings_to_improve_Tomcat_performance.3F

Kind Regards, Claude

2
  • Thanks. This is what I was looking for: someone who has a similar setup and can confirm what I have is normal.
    – Tanner
    Aug 11, 2011 at 13:26
  • I have a vserver with 1 gB dedicated and 2gB dynamic ram. i am really happy about that 1gB dedicated, Apache + Mysql + MailServer + Tomcat take 700mB together.
    – Claude
    Aug 11, 2011 at 17:14
1

Jvm is a memory hungry environment and 512megs is probably too low for the OS plus a jvm running a medium size app. Also, if you are targeting so low memory consumption you should use a 32bit version of both the OS and JRE. You may also try a lower footprint container such as Jetty.

0
0

RES = RESident Size (how much of your program is in actual, physical RAM.
VIRT = VIRTual Memory Footprint (how much virtual memory, RAM + Swap, your program has allocated).

Is this normal? Maybe, maybe not.
Restart tomcat. Is the VIRTual size substantially smaller? Does it grow over time? If so, you have a memory leak (either in Tomcat or in your application).
You can deal with this by digging through the code to find the leak, or by scheduling periodic restarts. The former is the RIGHT way, the latter the QUICK way.

If the Virtual size of your tomcat process is the same after a restart, or grows to a fixed point and doesn't get any larger, you don't have a classic memory leak: Your application just likes to use a lot of memory.
You can refactor to use less memory, or upgrade your hosting plan to allow you to use more memory without going over your limit.

Since you say there are no apps running in Tomcat right now this may just be the default amount of memory Java grabs for the JVM Heap at startup. That size is configurable (via Java parameters. See the Tomcat user's guide and other docs for info).

1
  • 1. The VIRT size immediately uses that much memory and does not grow. 2. The heap size is set via -Xmx=128M, so it shouldn't be an issue with that.
    – Tanner
    Aug 2, 2011 at 16:01
0

I recently got VPS with 392MB and installed Ubuntu 10.04 + Sun JDK 6 + vanilla Tomcat 6.0.32.

I was also surprised when saw that Tomcat default installation eats 384-400 MB

root@mybox:# top | grep java
32321 root      18   0  384m 121m 9996 S  0.0 31.7   0:12.24 java

The following script determines the real memory VPS is using and it proved that I'm running out of my 392Mb

#!/bin/bash
bean=`cat /proc/user_beancounters`
guar=`echo "$bean" | grep vmguar | awk '{ print $4;}'`
burst=`echo "$bean" | grep privvm | awk '{ print $5;}'`
priv=`echo "$bean" | grep privvm | awk '{ print $2;}'`
let total=guar/256
let used=priv/256
let burst=burst/256
echo "VPS memory usage:"
echo "Used: $used MB"
echo "Total: $total MB"
echo "Burstable to: $burst MB"

I have put JAVA_OPTS='-Xms128m -Xmx192m' in the /etc/environment but this did not help.

I started to google a solution, and encounntered yr post, so at least I'm not alone.

My j2ee application uses openJPA which is also memory consuming, so I think I will need to bye additional 256MB.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .