You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Gamigin Gamigin <ga...@gmail.com> on 2006/07/23 00:13:16 UTC

Tomcat Memory Status?

I've been having OutOfMemory problems and I've been watching the
"Server Status" section under Tomcat Manager. Immediately after
starting Tomcat (with my main application undeployed) I see:

Free memory: 2.17 MB Total memory: 5.84 MB Max memory: 63.56 MB

Can anyone explain what these numbers mean? I can't find any
explanation in the Tomcat documentation. What is the difference
between Total memory and Max memory? Free memory is a lot lower than
expected for just starting the server. I can't only have 2MB available
after starting the server and not even running my application.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat Memory Status?

Posted by Hassan Schroeder <ha...@gmail.com>.
On 7/22/06, Gamigin Gamigin <ga...@gmail.com> wrote:
> I've been having OutOfMemory problems and I've been watching the
> "Server Status" section under Tomcat Manager. Immediately after
> starting Tomcat (with my main application undeployed) I see:
>
> Free memory: 2.17 MB Total memory: 5.84 MB Max memory: 63.56 MB
>
> Can anyone explain what these numbers mean? I can't find any
> explanation in the Tomcat documentation. What is the difference
> between Total memory and Max memory? Free memory is a lot lower than
> expected for just starting the server. I can't only have 2MB available
> after starting the server and not even running my application.

Sure you can. :-)  The default JVM size of 64Mb is ridiculously small.
Bump it up to ~256Mb at least...

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat Memory Status?

Posted by Hassan Schroeder <ha...@gmail.com>.
On 7/23/06, Christopher Schultz <ch...@christopherschultz.net> wrote:

> There is plenty of memory left. If you notice, you have ~1MB free out of
> ~5MB: you still have ~58MB of memory to expand into before you start
> /really/ running out of memory.

Thanks, apparently I've been misinterpreting those numbers for, well,
ever :-)

A little experimentation shows that Tomcat with only the manager app
will run with ` -Xms4m -Xmx4m` (at 2m it immediately exits OOM).

Guess I should revisit some of my webapps' memory usage :-)

-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat Memory Status?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Hassan,

>> Another poster suggested that you increase your max heap size.
> 
> ...though the original poster said his app *wasn't deployed*.
> 
> A fresh install of 5.5.17 with *no* contexts other than the manager --
> started up with default catalina.sh script -- starts with:
> 
> Free memory: 1.40 MB Total memory: 4.93 MB Max memory: 63.56 MB
> 
> I doubt anyone will get much of an application to run in that available
> free
> space. Hence my suggestion that the 64Mb default is pretty useless  :-)

There is plenty of memory left. If you notice, you have ~1MB free out of
~5MB: you still have ~58MB of memory to expand into before you start
/really/ running out of memory.

-chris



Re: Tomcat Memory Status?

Posted by Hassan Schroeder <ha...@gmail.com>.
On 7/22/06, Christopher Schultz <ch...@christopherschultz.net> wrote:

> Another poster suggested that you increase your max heap size. That is
> reasonable if your application actually needs more memory to function
> normally. I encourage you to analyze your memory needs and possibly
> increase the heap size to meet those needs. But, don't just jack up the
> heap size because you are running out of memory; you might have a
> resource leak

...though the original poster said his app *wasn't deployed*.

A fresh install of 5.5.17 with *no* contexts other than the manager --
started up with default catalina.sh script -- starts with:

Free memory: 1.40 MB Total memory: 4.93 MB Max memory: 63.56 MB

I doubt anyone will get much of an application to run in that available free
space. Hence my suggestion that the 64Mb default is pretty useless  :-)

YMMV,
-- 
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat Memory Status?

Posted by Stephen Caine <st...@commongrnd.com>.
Gamigin

> So with: Free memory: 2.17 MB Total memory: 5.84 MB Max memory:  
> 63.56 MB.  I really have approximately 63.56MB - 5.84MB + 2.17MB =  
> 59.89MB available which isn't really near tapping the server out.  
> Start worrying when Total Memory creeps up near Max Memory.

In addition to the excellent advise others have provided, don't  
overlook Permanent Generational Memory (PermGen).  If you load lot's  
of pages with many classes, you can easily exceed default values.

Stephen Caine
Soft Breeze Systems, LLC

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat Memory Status?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Gamigin,

> So with: Free memory: 2.17 MB Total memory: 5.84 MB Max memory: 63.56
> MB
> 
> I really have approximately 63.56MB - 5.84MB + 2.17MB = 59.89MB
> available which isn't really near tapping the server out. Start
> worrying when Total Memory creeps up near Max Memory.

Precisely.

There /are/ cases where the JVM needs to allocate a lot of memory in a
short period of time, and the GC cannot keep up with the allocation
requirements, and you get either an OutOfMemoryError or sometimes other
weird things going on. In these cases, it makes sense to first set the
initial heap size to the same as the max heap size, so that you get all
your Java heap memory allocated at once, before any real work gets done.
(This is why many folks on this list recommend setting init=max).

The other possibility is that you app simply needs more memory. If you
cache a lot of data, or store a lot of stuff in users' sessions, or
simply expect a ton of traffic with a lot going on at once, you may need
to raise your heap size.

-chris



Re: Tomcat Memory Status?

Posted by gamigin <ga...@gmail.com>.
Thank you both so much for the replies.

That makes perfect sense. To recap:
Max memory: The maximum amount of memory allowed to be allocated by the
Tomcat instance.
Total memory: The amount of memory that is currently allocated. Memory isn't
allocated until it is needed.
Free memory: The amount of free memory within the currently allocated block.
This doesn't include available memory that hasn't been allocated by Tomcat.

So with: Free memory: 2.17 MB Total memory: 5.84 MB Max memory: 63.56 MB 

I really have approximately 63.56MB - 5.84MB + 2.17MB = 59.89MB available
which isn't really near tapping the server out. Start worrying when Total
Memory creeps up near Max Memory.

Thanks guys



-- 
View this message in context: http://www.nabble.com/Tomcat-Memory-Status--tf1986210.html#a5452805
Sent from the Tomcat - User forum at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat Memory Status?

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Gamigin,

> Free memory: 2.17 MB Total memory: 5.84 MB Max memory: 63.56 MB
> 
> I can't only have 2MB available after starting the server and not
> even running my application.

If you have your starting heap size and maximum heap size set
differently, then you will see this kind of thing all the time. The JVM
only allocates heap space when it needs it.

If you have a max heap size of 64MB, and you have only needed 5-6MB to
load Tomcat, then you'll have 5-6MB of heap space allocated, some of it
freed after startup (in your case, 2.17MB) and a comparitively huge max
memory.

The JVM will continue to allocate heap space as necessary until you hit
that 64MB limit. At that point, the garbage collector will do a full GC
in an attempt to free more memory in order to allow you to create more
objects, etc. If the GC fails to free up enough memory by collecting old
objects, they you're hosed: you get yourself an OutOfMemoryError.

I hope that clears things up.

Another poster suggested that you increase your max heap size. That is
reasonable if your application actually needs more memory to function
normally. I encourage you to analyze your memory needs and possibly
increase the heap size to meet those needs. But, don't just jack up the
heap size because you are running out of memory; you might have a
resource leak, and they're a lot easier to track down and fix with a
smaller heap than a larger heap ('cause you can run out of memory faster ;).

-chris