You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Martin O'Shea <ap...@dsl.pipex.com> on 2011/12/09 15:37:17 UTC

Tomcat memory allocation

Hello

Following advice found elsewhere on the internet, I've just added the
following line to the catalina.bat file in my installation of tomcat 6.0.26:

set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m -XX:MaxPermSize=128m

I know that settings:

Xms128m -Xmx512m

Control the initial heap size and what it can expand to. But what exactly
is:

-XX:MaxPermSize=128m

Should it be set to an addition of the other settings, or the other settings
to an addition of it?

Thanks

Martin O'Shea



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


RE: Tomcat memory allocation

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Martin O'Shea [mailto:appy74@dsl.pipex.com] 
> Subject: RE: Tomcat memory allocation

> Sorry to belabour this but if I create a setenv.bat file with settings:
> set CATALINA_OPTS=%CATALINA_OPTS% -Xms128m -Xmx768m -XX:MaxPermSize=128m
> where should the file go and does it need to be called from anywhere?

Put it in Tomcat's bin directory.  The startup scripts look for it and call it if found.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


RE: Tomcat memory allocation

Posted by Martin O'Shea <ap...@dsl.pipex.com>.
Sorry to belabour this but if I create a setenv.bat file with settings:

set CATALINA_OPTS=%CATALINA_OPTS% -Xms128m -Xmx768m -XX:MaxPermSize=128m

where should the file go and does it need to be called from anywhere?

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: 09 Dec 2011 15 29
To: Tomcat Users List
Subject: RE: Tomcat memory allocation

> From: Martin O'Shea [mailto:appy74@dsl.pipex.com]
> Subject: RE: Tomcat memory allocation

> But if I change the settings in catalina.bat to:

Don't make changes to catalina.bat; create a setenv.bat to hold all your
local settings.

> set CATALINA_OPTS=%CATALINA_OPTS% -Xms128m -Xmx768m 
> -XX:MaxPermSize=128m

> In Tomcat Manager I see:

Use a real JVM analysis tool (e.g., JConsole, VisualVM), not the manager
webapp.

> Free memory: 97.90 MB Total memory: 122.68 MB Max memory: 227.56 MB 
> Shouldn't total or max memory have a higher reading?

No, since the heap size is sliding around between Xms and Xmx.

You might want to take a look at the papers here:

http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140228.html

Especially interesting are the ergonomics and tuning ones.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you received
this in error, please contact the sender and delete the e-mail and its
attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@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 allocation

Posted by André Warnier <aw...@ice-sa.com>.
Martin O'Shea wrote:
> I should add that Tomcat is running as a Windows service, it isn't started
> manually.

Then the .bat files are not used.
Call up the tomcat?w.exe program, and edit the settings in the Java tab.

> 
> -----Original Message-----
> From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
> Sent: 09 Dec 2011 15 29
> To: Tomcat Users List
> Subject: RE: Tomcat memory allocation
> 
>> From: Martin O'Shea [mailto:appy74@dsl.pipex.com]
>> Subject: RE: Tomcat memory allocation
> 
>> But if I change the settings in catalina.bat to:
> 
> Don't make changes to catalina.bat; create a setenv.bat to hold all your
> local settings.
> 
>> set CATALINA_OPTS=%CATALINA_OPTS% -Xms128m -Xmx768m 
>> -XX:MaxPermSize=128m
> 
>> In Tomcat Manager I see:
> 
> Use a real JVM analysis tool (e.g., JConsole, VisualVM), not the manager
> webapp.
> 
>> Free memory: 97.90 MB Total memory: 122.68 MB Max memory: 227.56 MB 
>> Shouldn't total or max memory have a higher reading?
> 
> No, since the heap size is sliding around between Xms and Xmx.
> 
> You might want to take a look at the papers here:
> 
> http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140228.html
> 
> Especially interesting are the ergonomics and tuning ones.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you received
> this in error, please contact the sender and delete the e-mail and its
> attachments from all computers.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@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 allocation

Posted by Pid <pi...@pidster.com>.
On 09/12/2011 16:37, André Warnier wrote:
> David kerber wrote:
>> On 12/9/2011 10:49 AM, Caldarale, Charles R wrote:
>>>> From: Martin O'Shea [mailto:appy74@dsl.pipex.com]
>>>> Subject: RE: Tomcat memory allocation
>>>
>>>> I should add that Tomcat is running as a Windows service,
>>>> it isn't started manually.
>>>
>>> In that case, nothing that we've been discussing about JAVA_OPTS,
>>> CATALINA_OPTS, startup.bat, catalina.bat, and setenv.bat is
>>> relevant.  All JVM config settings need to be done with the
>>> tomcat?w.exe program.
>>
>> Or directly in the registry (tomcat?w just changes those entries).
>>
> I wouldn't do that. According to Microsoft, editing the Registry
> directly can cause your teeth to turn green and rot, your hair to fall
> off your head and grow on your back, and can cause the java heap to boil
> over and stain your keyboard.

This man tried editing the registry BY HAND:

 http://www.youtube.com/watch?v=wvsboPUjrGc


p



-- 

[key:62590808]


Re: Tomcat memory allocation

Posted by André Warnier <aw...@ice-sa.com>.
David kerber wrote:
> On 12/9/2011 10:49 AM, Caldarale, Charles R wrote:
>>> From: Martin O'Shea [mailto:appy74@dsl.pipex.com]
>>> Subject: RE: Tomcat memory allocation
>>
>>> I should add that Tomcat is running as a Windows service,
>>> it isn't started manually.
>>
>> In that case, nothing that we've been discussing about JAVA_OPTS, 
>> CATALINA_OPTS, startup.bat, catalina.bat, and setenv.bat is relevant.  
>> All JVM config settings need to be done with the tomcat?w.exe program.
> 
> Or directly in the registry (tomcat?w just changes those entries).
> 
I wouldn't do that. According to Microsoft, editing the Registry directly can cause your 
teeth to turn green and rot, your hair to fall off your head and grow on your back, and 
can cause the java heap to boil over and stain your keyboard.

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


RE: Tomcat memory allocation

Posted by Jeffrey Janner <Je...@PolyDyne.com>.
> -----Original Message-----
> From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
> Sent: Friday, December 09, 2011 10:35 AM
> To: Tomcat Users List
> Subject: RE: Tomcat memory allocation
> 
> > From: Martin O'Shea [mailto:appy74@dsl.pipex.com]
> > Subject: RE: Tomcat memory allocation
> 
> > I believe I should be looking in the Windows Registry
> 
> DO NOT edit the Windows registry - you will break something.  Use the
> tomcat?w.exe utility; that's what it's for.
> 
>  - Chuck

Make all changes in the Java tab.  Set max & min heap settings in their little spaces at the bottom, and add any other Java options you desire, e.g. "-XX:MaxPermSize=512m" as separate lines in that great big box in the middle.
Jeff
__________________________________________________________________________

Confidentiality Notice:  This Transmission (including any attachments) may contain information that is privileged, confidential, and exempt from disclosure under applicable law.  If the reader of this message is not the intended recipient you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited.  

If you have received this transmission in error, please immediately reply to the sender or telephone (512) 343-9100 and delete this transmission from your system.


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


RE: Tomcat memory allocation

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Martin O'Shea [mailto:appy74@dsl.pipex.com] 
> Subject: RE: Tomcat memory allocation

> I believe I should be looking in the Windows Registry

DO NOT edit the Windows registry - you will break something.  Use the tomcat?w.exe utility; that's what it's for.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

 


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


RE: Tomcat memory allocation

Posted by Martin O'Shea <ap...@dsl.pipex.com>.
This gets weirder. I believe I should be looking in the Windows Registry
under:

 

HKEY_LOCAL_MACHINE

SOFTWARE

Apache Software Foundation

Procrun 2,0

 

But I have no such settings. I simply have:

 

(Default)

InstallPath

Version

 

But I have:

 

JvmMS (set to 128)

jvmMX (set to 256)

 

Under 

 

HKEY_LOCAL_MACHINE

SOFTWARE

Wow6432Node

Apache Software Foundation

Procrun 2.0

Tomcat 6

Parameters

Java

 

If I want to increase Xmx memory, is  jvmMX the one to edit? Or both to set
them to the same value.

 

 

-----Original Message-----

From: David kerber [mailto:dckerber@verizon.net] 

Sent: 09 Dec 2011 16 02

To: users@tomcat.apache.org

Subject: Re: Tomcat memory allocation

 

On 12/9/2011 10:49 AM, Caldarale, Charles R wrote:

>> From: Martin O'Shea [mailto:appy74@dsl.pipex.com]

>> Subject: RE: Tomcat memory allocation

> 

>> I should add that Tomcat is running as a Windows service, it isn't 

>> started manually.

> 

> In that case, nothing that we've been discussing about JAVA_OPTS,
CATALINA_OPTS, startup.bat, catalina.bat, and setenv.bat is relevant.  All
JVM config settings need to be done with the tomcat?w.exe program.

 

Or directly in the registry (tomcat?w just changes those entries).

 

 

---------------------------------------------------------------------

To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org

For additional commands, e-mail: users-help@tomcat.apache.org

 


Re: Tomcat memory allocation

Posted by David kerber <dc...@verizon.net>.
On 12/9/2011 10:49 AM, Caldarale, Charles R wrote:
>> From: Martin O'Shea [mailto:appy74@dsl.pipex.com]
>> Subject: RE: Tomcat memory allocation
>
>> I should add that Tomcat is running as a Windows service,
>> it isn't started manually.
>
> In that case, nothing that we've been discussing about JAVA_OPTS, CATALINA_OPTS, startup.bat, catalina.bat, and setenv.bat is relevant.  All JVM config settings need to be done with the tomcat?w.exe program.

Or directly in the registry (tomcat?w just changes those entries).


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


RE: Tomcat memory allocation

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Martin O'Shea [mailto:appy74@dsl.pipex.com] 
> Subject: RE: Tomcat memory allocation

> I should add that Tomcat is running as a Windows service, 
> it isn't started manually.

In that case, nothing that we've been discussing about JAVA_OPTS, CATALINA_OPTS, startup.bat, catalina.bat, and setenv.bat is relevant.  All JVM config settings need to be done with the tomcat?w.exe program.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


RE: Tomcat memory allocation

Posted by Martin O'Shea <ap...@dsl.pipex.com>.
I should add that Tomcat is running as a Windows service, it isn't started
manually.

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: 09 Dec 2011 15 29
To: Tomcat Users List
Subject: RE: Tomcat memory allocation

> From: Martin O'Shea [mailto:appy74@dsl.pipex.com]
> Subject: RE: Tomcat memory allocation

> But if I change the settings in catalina.bat to:

Don't make changes to catalina.bat; create a setenv.bat to hold all your
local settings.

> set CATALINA_OPTS=%CATALINA_OPTS% -Xms128m -Xmx768m 
> -XX:MaxPermSize=128m

> In Tomcat Manager I see:

Use a real JVM analysis tool (e.g., JConsole, VisualVM), not the manager
webapp.

> Free memory: 97.90 MB Total memory: 122.68 MB Max memory: 227.56 MB 
> Shouldn't total or max memory have a higher reading?

No, since the heap size is sliding around between Xms and Xmx.

You might want to take a look at the papers here:

http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140228.html

Especially interesting are the ergonomics and tuning ones.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you received
this in error, please contact the sender and delete the e-mail and its
attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@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 allocation

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Martin O'Shea [mailto:appy74@dsl.pipex.com] 
> Subject: RE: Tomcat memory allocation

> But if I change the settings in catalina.bat to:

Don't make changes to catalina.bat; create a setenv.bat to hold all your local settings.

> set CATALINA_OPTS=%CATALINA_OPTS% -Xms128m -Xmx768m -XX:MaxPermSize=128m

> In Tomcat Manager I see:

Use a real JVM analysis tool (e.g., JConsole, VisualVM), not the manager webapp.

> Free memory: 97.90 MB Total memory: 122.68 MB Max memory: 227.56 MB
> Shouldn't total or max memory have a higher reading?

No, since the heap size is sliding around between Xms and Xmx.

You might want to take a look at the papers here:

http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140228.html

Especially interesting are the ergonomics and tuning ones.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


RE: Tomcat memory allocation

Posted by Martin O'Shea <ap...@dsl.pipex.com>.
Thanks Chuck. But if I change the settings in catalina.bat to:

set CATALINA_OPTS=%CATALINA_OPTS% -Xms128m -Xmx768m -XX:MaxPermSize=128m

In Tomcat Manager I see:

Free memory: 97.90 MB Total memory: 122.68 MB Max memory: 227.56 MB

Shouldn't total or max memory have a higher reading?

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: 09 Dec 2011 15 03
To: Tomcat Users List
Subject: RE: Tomcat memory allocation

> From: Martin O'Shea [mailto:appy74@dsl.pipex.com]
> Subject: RE: Tomcat memory allocation

> So I could reduce it below 128Mb if I choose. Is there a default 
> value?

Yes - for each platform and JVM type.  Use JConsole on a running JVM to see
what it is.

> A job hung earlier and I wonder if memory was to blame although there 
> is nothing in the system or server logs to say so.

That's what stack traces are for.  Use JConsole or jstack to see what's
going on in a running JVM.  Much better to investigate than throw darts at
the problem and hope you hit the target.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you received
this in error, please contact the sender and delete the e-mail and its
attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@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 allocation

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Martin O'Shea [mailto:appy74@dsl.pipex.com] 
> Subject: RE: Tomcat memory allocation

> So I could reduce it below 128Mb if I choose. Is there a
> default value?

Yes - for each platform and JVM type.  Use JConsole on a running JVM to see what it is.

> A job hung earlier and I wonder if memory was to blame 
> although there is nothing in the system or server logs
> to say so.

That's what stack traces are for.  Use JConsole or jstack to see what's going on in a running JVM.  Much better to investigate than throw darts at the problem and hope you hit the target.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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


Re: Tomcat memory allocation

Posted by "Mark H. Wood" <mw...@IUPUI.Edu>.
On Fri, Dec 09, 2011 at 02:52:23PM -0000, Martin O'Shea wrote:
> Thanks for this Chuck. I realise now what is happening. I thought the
> PermGen space was used in the heap when now I see it as just storing class
> definitions. So I could reduce it below 128Mb if I choose. Is there a
> default value?

There are defaults for all of the settings, in Java not Tomcat.

But defaults are irrelevant in production.  Tuning is always with
respect to your workload, not someone else's averages.  You need to
give more resources to your application until it starts and runs under
modest load, then monitor its resource utilization and make further
adjustments to give it enough headroom for unexpected load spikes
without wasting resources which will never be used.  Then monitor
periodically to be sure you haven't missed anything.

-- 
Mark H. Wood, Lead System Programmer   mwood@IUPUI.Edu
Asking whether markets are efficient is like asking whether people are smart.

RE: Tomcat memory allocation

Posted by Daniel Mikusa <dm...@vmware.com>.
On Fri, 2011-12-09 at 06:52 -0800, Martin O'Shea wrote:
> Thanks for this Chuck. I realise now what is happening. I thought the
> PermGen space was used in the heap when now I see it as just storing class
> definitions. So I could reduce it below 128Mb if I choose. Is there a
> default value?

This is a useful article which describes many of the common JVM options
and their defaults.

http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

It lists "-XX:MaxPermSize" as a default of 64M with the following
exceptions:  "[5.0 and newer: 64 bit VMs are scaled 30% larger; 1.4
amd64: 96m; 1.3.1 -client: 32m.]".

If I connect to a Java process on my Linux system with a 64-bit JVM, I
see a max of roughly 64M + 30% (i.e. about 83M).

Dan



> 
> As to setting Xms and Xmx to the same, I will do that. A job hung earlier
> and I wonder if memory was to blame although there is nothing in the system
> or server logs to say so.
> 
> -----Original Message-----
> From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
> Sent: 09 Dec 2011 14 46
> To: Tomcat Users List
> Subject: RE: Tomcat memory allocation
> 
> > From: Martin O'Shea [mailto:appy74@dsl.pipex.com]
> > Subject: Tomcat memory allocation
> 
> > Following advice found elsewhere on the internet
> 
> Always to be taken with large chunks of salt.
> 
> > set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m -XX:MaxPermSize=128m
> 
> You would be better off using CATALINA_OPTS, since setting JAVA_OPTS
> pointlessly affects the shutdown script as well as the startup one.
> 
> > I know that settings:
> > Xms128m -Xmx512m
> 
> > Control the initial heap size and what it can expand to.
> 
> In a server environment, you normally want Xms and Xmx set to the same value
> to avoid heap thrashing.  The exact size is completely dependent on what
> your webapps need.
> 
> > But what exactly is:
> > -XX:MaxPermSize=128m
> 
> It's the amount of space to which the so-called permanent generation can
> expand.  PermGen holds primarily instances of java.lang.Class, so it only
> needs to be specified if you have a large number of classes in your
> environment.
> 
> > Should it be set to an addition of the other settings, or the other 
> > settings to an addition of it?
> 
> What does that question mean?  PermGen size is completely independent of the
> heap size.
> 
> Make sure you have enough RAM available on the system to support the Xmx +
> PermGen + a_lot_of_other_stuff.  Monitor the system to make sure you're not
> getting into paging.
> 
>  - Chuck
> 
> 
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you received
> this in error, please contact the sender and delete the e-mail and its
> attachments from all computers.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@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 allocation

Posted by "Ronald Klop (Mailing List)" <ro...@base.nl>.


Op vrijdag, 9 december 2011 16:11 schreef Pid <pi...@pidster.com>:
> 
> 
> 
> On 09/12/2011 14:52, Martin O'Shea wrote:
> 
> > -----Original Message-----
> > From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com]
> > Sent: 09 Dec 2011 14 46
> > To: Tomcat Users List
> > Subject: RE: Tomcat memory allocation
> >
> >> From: Martin O'Shea [mailto:appy74@dsl.pipex.com]
> >> Subject: Tomcat memory allocation
> >
> >> Following advice found elsewhere on the internet
> >
> > Always to be taken with large chunks of salt.
> >
> >> set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m -XX:MaxPermSize=128m
> >
> > You would be better off using CATALINA_OPTS, since setting JAVA_OPTS
> > pointlessly affects the shutdown script as well as the startup one.
> >
> >> I know that settings:
> >> Xms128m -Xmx512m
> >
> >> Control the initial heap size and what it can expand to.
> >
> > In a server environment, you normally want Xms and Xmx set to the same value
> > to avoid heap thrashing.  The exact size is completely dependent on what
> > your webapps need.
> >
> >> But what exactly is:
> >> -XX:MaxPermSize=128m
> >
> > It's the amount of space to which the so-called permanent generation can
> > expand.  PermGen holds primarily instances of java.lang.Class, so it only
> > needs to be specified if you have a large number of classes in your
> > environment.
> >
> >> Should it be set to an addition of the other settings, or the other
> >> settings to an addition of it?
> >
> > What does that question mean?  PermGen size is completely independent of the
> > heap size.
> >
> > Make sure you have enough RAM available on the system to support the Xmx +
> > PermGen + a_lot_of_other_stuff.  Monitor the system to make sure you're not
> > getting into paging.
> >
> >  
> > Thanks for this Chuck. I realise now what is happening. I thought the
> > PermGen space was used in the heap when now I see it as just storing class
> > definitions. So I could reduce it below 128Mb if I choose. Is there a
> > default value?
> >
> > As to setting Xms and Xmx to the same, I will do that. A job hung earlier
> > and I wonder if memory was to blame although there is nothing in the
> system
> > or server logs to say so.
> 
> Connect VisualVM to your Tomcat instance and use the monitor tab to
> observe the actual PermGen usage.  It should be pretty stable, unless
> you're doing something funky like generating classes or using RMI.
> 
> You'll then know how much you need to allocate.
> 
> 
> p
> 
> 
> 
> 
> -- 
> 
> [key:62590808]
>  
> 
> 
> 
> 
> 
> 

Don't forget jstat also:
$ jstat -gc -h 10 -t 84762 3s
Timestamp        S0C    S1C    S0U    S1U      EC       EU        OC         OU       PC     PU    YGC     YGCT    FGC    FGCT     GCT  
       700819.2 1792.0 1792.0 288.0   0.0    640.0    289.2    80320.0    61284.6   95296.0 95013.7    516    3.182  200    64.692   67.874
       700822.2 1792.0 1792.0 288.0   0.0    640.0    289.2    80320.0    61284.6   95296.0 95013.7    516    3.182  200    64.692   67.874
       700825.2 1792.0 1792.0 288.0   0.0    640.0    289.2    80320.0    61284.6   95296.0 95013.7    516    3.182  200    64.692   67.874
       700828.2 1792.0 1792.0 288.0   0.0    640.0    289.2    80320.0    61284.6   95296.0 95013.7    516    3.182  200    64.692   67.874
       700831.1 1792.0 1792.0 288.0   0.0    640.0    315.5    80320.0    61284.6   95296.0 95013.7    516    3.182  200    64.692   67.874
       700834.2 1792.0 1792.0 288.0   0.0    640.0    323.0    80320.0    61284.6   95296.0 95013.7    516    3.182  200    64.692   67.874
       700837.2 1792.0 1792.0 288.0   0.0    640.0    323.0    80320.0    61284.6   95296.0 95013.7    516    3.182  200    64.692   67.874
Ronald.

Re: Tomcat memory allocation

Posted by Pid <pi...@pidster.com>.
On 09/12/2011 14:52, Martin O'Shea wrote:

> -----Original Message-----
> From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
> Sent: 09 Dec 2011 14 46
> To: Tomcat Users List
> Subject: RE: Tomcat memory allocation
> 
>> From: Martin O'Shea [mailto:appy74@dsl.pipex.com]
>> Subject: Tomcat memory allocation
> 
>> Following advice found elsewhere on the internet
> 
> Always to be taken with large chunks of salt.
> 
>> set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m -XX:MaxPermSize=128m
> 
> You would be better off using CATALINA_OPTS, since setting JAVA_OPTS
> pointlessly affects the shutdown script as well as the startup one.
> 
>> I know that settings:
>> Xms128m -Xmx512m
> 
>> Control the initial heap size and what it can expand to.
> 
> In a server environment, you normally want Xms and Xmx set to the same value
> to avoid heap thrashing.  The exact size is completely dependent on what
> your webapps need.
> 
>> But what exactly is:
>> -XX:MaxPermSize=128m
> 
> It's the amount of space to which the so-called permanent generation can
> expand.  PermGen holds primarily instances of java.lang.Class, so it only
> needs to be specified if you have a large number of classes in your
> environment.
> 
>> Should it be set to an addition of the other settings, or the other 
>> settings to an addition of it?
> 
> What does that question mean?  PermGen size is completely independent of the
> heap size.
> 
> Make sure you have enough RAM available on the system to support the Xmx +
> PermGen + a_lot_of_other_stuff.  Monitor the system to make sure you're not
> getting into paging.
> 
>  
> Thanks for this Chuck. I realise now what is happening. I thought the
> PermGen space was used in the heap when now I see it as just storing class
> definitions. So I could reduce it below 128Mb if I choose. Is there a
> default value?
>
> As to setting Xms and Xmx to the same, I will do that. A job hung earlier
> and I wonder if memory was to blame although there is nothing in the
system
> or server logs to say so.

Connect VisualVM to your Tomcat instance and use the monitor tab to
observe the actual PermGen usage.  It should be pretty stable, unless
you're doing something funky like generating classes or using RMI.

You'll then know how much you need to allocate.


p




-- 

[key:62590808]


RE: Tomcat memory allocation

Posted by Martin O'Shea <ap...@dsl.pipex.com>.
Thanks for this Chuck. I realise now what is happening. I thought the
PermGen space was used in the heap when now I see it as just storing class
definitions. So I could reduce it below 128Mb if I choose. Is there a
default value?

As to setting Xms and Xmx to the same, I will do that. A job hung earlier
and I wonder if memory was to blame although there is nothing in the system
or server logs to say so.

-----Original Message-----
From: Caldarale, Charles R [mailto:Chuck.Caldarale@unisys.com] 
Sent: 09 Dec 2011 14 46
To: Tomcat Users List
Subject: RE: Tomcat memory allocation

> From: Martin O'Shea [mailto:appy74@dsl.pipex.com]
> Subject: Tomcat memory allocation

> Following advice found elsewhere on the internet

Always to be taken with large chunks of salt.

> set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m -XX:MaxPermSize=128m

You would be better off using CATALINA_OPTS, since setting JAVA_OPTS
pointlessly affects the shutdown script as well as the startup one.

> I know that settings:
> Xms128m -Xmx512m

> Control the initial heap size and what it can expand to.

In a server environment, you normally want Xms and Xmx set to the same value
to avoid heap thrashing.  The exact size is completely dependent on what
your webapps need.

> But what exactly is:
> -XX:MaxPermSize=128m

It's the amount of space to which the so-called permanent generation can
expand.  PermGen holds primarily instances of java.lang.Class, so it only
needs to be specified if you have a large number of classes in your
environment.

> Should it be set to an addition of the other settings, or the other 
> settings to an addition of it?

What does that question mean?  PermGen size is completely independent of the
heap size.

Make sure you have enough RAM available on the system to support the Xmx +
PermGen + a_lot_of_other_stuff.  Monitor the system to make sure you're not
getting into paging.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you received
this in error, please contact the sender and delete the e-mail and its
attachments from all computers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@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 allocation

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Martin O'Shea [mailto:appy74@dsl.pipex.com] 
> Subject: Tomcat memory allocation

> Following advice found elsewhere on the internet

Always to be taken with large chunks of salt.

> set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m -XX:MaxPermSize=128m

You would be better off using CATALINA_OPTS, since setting JAVA_OPTS pointlessly affects the shutdown script as well as the startup one.

> I know that settings:
> Xms128m -Xmx512m

> Control the initial heap size and what it can expand to.

In a server environment, you normally want Xms and Xmx set to the same value to avoid heap thrashing.  The exact size is completely dependent on what your webapps need.

> But what exactly is:
> -XX:MaxPermSize=128m

It's the amount of space to which the so-called permanent generation can expand.  PermGen holds primarily instances of java.lang.Class, so it only needs to be specified if you have a large number of classes in your environment.

> Should it be set to an addition of the other settings,
> or the other settings to an addition of it?

What does that question mean?  PermGen size is completely independent of the heap size.

Make sure you have enough RAM available on the system to support the Xmx + PermGen + a_lot_of_other_stuff.  Monitor the system to make sure you're not getting into paging.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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