You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Alfredo Alessandrini <al...@gmail.com> on 2012/02/14 14:07:21 UTC

memory heap size

Hi,

I'm running tomcat 7.0.25 in a shared server (centOS 64bit).

Memory limit for my account is 256m.

I'm running tomcat with this settings:

export CATALINA_OPTS="-Xms128m -Xmx256m"

export JAVA_OPTS="-Xms128m -Xmx256m"

But the process exceed the limit that I've set:

RSS ELAPSED PID COMMAND
318340 01:14 37152 /home/keol/java/bin/java
-Djava.util.logging.config.file=/home/keol/webapps/tomcat/conf/logging.properties
-Xms64m -Xmx128m
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Xms64m -Xmx128m
-Djava.endorsed.dirs=/home/keol/webapps/tomcat/endorsed -classpath
/home/keol/webapps/tomcat/bin/bootstrap.jar:/home/keol/webapps/tomcat/bin/tomcat-juli.jar
-Dcatalina.base=/home/keol/webapps/tomcat
-Dcatalina.home=/home/keol/webapps/tomcat
-Djava.io.tmpdir=/home/keol/webapps/tomcat/temp
org.apache.catalina.startup.Bootstrap start

There is a way to limit the memory usage?


thanks,

Alfredo

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


Re: memory heap size

Posted by Pid <pi...@pidster.com>.
On 14/02/2012 20:58, Christopher Schultz wrote:
> 
> 
> On 2/14/12 3:41 PM, André Warnier wrote:
>>>
>>> Or just get a mess restrictive hosting environment.
>>>
>> Or a lore permissive one.
> 
> LOL

:)

Habbing a code affects my spelling.


p


-- 

[key:62590808]


Re: memory heap size

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



On 2/14/12 3:41 PM, André Warnier wrote:
>> 
>> Or just get a mess restrictive hosting environment.
>> 
> Or a lore permissive one.

LOL
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk86yuEACgkQ9CaO5/Lv0PC5kQCfbHvbS915D4a4IGBjOVjLmmz7
EgcAn1lCW4JfRCZeuzQP+gRpkfJYMHec
=IfRx
-----END PGP SIGNATURE-----

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


Re: memory heap size

Posted by André Warnier <aw...@ice-sa.com>.
Pid * wrote:
> On 14 Feb 2012, at 17:11, Christopher Schultz
> <ch...@christopherschultz.net> wrote:
> 
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Alfredo,
>>
>> On 2/14/12 10:05 AM, Alfredo Alessandrini wrote:
>>> Now I've put in setenv.sh this settings:
>>>
>>> export JAVA_OPTS="-Xms64m -Xmx128m -XX:MaxPermSize=128m"
>> So, you have a user limit of 256MiB and you have your heap set to
>> 128MiB and your max perm gen set to 128MiB. What about thread stacks?
>> What about native stack and heap?
>>
>> There's a lot to a Java process besides what -Xmx can limit.
>>
>> Also, if your *user* is limited to 256MiB then you also have to think
>> about all the other things you are going to want to run -- like
>> /bin/sh, /bin/ls, etc. that also take a bit of memory. You're going to
>> need to start up a JVM in order to shut-down Tomcat if you want to use
>> bin/shutdown.sh (there are other ways to shut down Tomcat if that's a
>> problem).
>>
>> I'm not sure there is a way to tell Java not to use more than a
>> particular amount of total memory. If it were me, I'd make the maximum
>> heap size as small as you think you can get away with (can you do
>> 32MiB? 64MiB?) and leave everything else alone until you have a problem.
> 
> Or just get a mess restrictive hosting environment.
> 
Or a lore permissive one.

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


Re: memory heap size

Posted by Pid * <pi...@pidster.com>.
On 14 Feb 2012, at 17:11, Christopher Schultz
<ch...@christopherschultz.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Alfredo,
>
> On 2/14/12 10:05 AM, Alfredo Alessandrini wrote:
>> Now I've put in setenv.sh this settings:
>>
>> export JAVA_OPTS="-Xms64m -Xmx128m -XX:MaxPermSize=128m"
>
> So, you have a user limit of 256MiB and you have your heap set to
> 128MiB and your max perm gen set to 128MiB. What about thread stacks?
> What about native stack and heap?
>
> There's a lot to a Java process besides what -Xmx can limit.
>
> Also, if your *user* is limited to 256MiB then you also have to think
> about all the other things you are going to want to run -- like
> /bin/sh, /bin/ls, etc. that also take a bit of memory. You're going to
> need to start up a JVM in order to shut-down Tomcat if you want to use
> bin/shutdown.sh (there are other ways to shut down Tomcat if that's a
> problem).
>
> I'm not sure there is a way to tell Java not to use more than a
> particular amount of total memory. If it were me, I'd make the maximum
> heap size as small as you think you can get away with (can you do
> 32MiB? 64MiB?) and leave everything else alone until you have a problem.

Or just get a mess restrictive hosting environment.


p


>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
> Comment: GPGTools - http://gpgtools.org
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk86lbYACgkQ9CaO5/Lv0PBvbQCglpC2svqYOLsAm9ZNiqDZlSE7
> X3oAn2K3TomYc20Hki+sT3Aj9TOKQr82
> =/siH
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> 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: memory heap size

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Alfredo,

On 2/14/12 10:05 AM, Alfredo Alessandrini wrote:
> Now I've put in setenv.sh this settings:
> 
> export JAVA_OPTS="-Xms64m -Xmx128m -XX:MaxPermSize=128m"

So, you have a user limit of 256MiB and you have your heap set to
128MiB and your max perm gen set to 128MiB. What about thread stacks?
What about native stack and heap?

There's a lot to a Java process besides what -Xmx can limit.

Also, if your *user* is limited to 256MiB then you also have to think
about all the other things you are going to want to run -- like
/bin/sh, /bin/ls, etc. that also take a bit of memory. You're going to
need to start up a JVM in order to shut-down Tomcat if you want to use
bin/shutdown.sh (there are other ways to shut down Tomcat if that's a
problem).

I'm not sure there is a way to tell Java not to use more than a
particular amount of total memory. If it were me, I'd make the maximum
heap size as small as you think you can get away with (can you do
32MiB? 64MiB?) and leave everything else alone until you have a problem.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk86lbYACgkQ9CaO5/Lv0PBvbQCglpC2svqYOLsAm9ZNiqDZlSE7
X3oAn2K3TomYc20Hki+sT3Aj9TOKQr82
=/siH
-----END PGP SIGNATURE-----

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


Re: memory heap size

Posted by Alfredo Alessandrini <al...@gmail.com>.
It's started with:

[keol@web ~]$ webapps/tomcat/bin/startup.sh
Using CATALINA_BASE:   /home/keol/webapps/tomcat
Using CATALINA_HOME:   /home/keol/webapps/tomcat
Using CATALINA_TMPDIR: /home/keol/webapps/tomcat/temp
Using JRE_HOME:        /home/keol/java
Using CLASSPATH:
/home/keol/webapps/tomcat/bin/bootstrap.jar:/home/keol/webapps/tomcat/bin/tomcat-juli.jar


Now I've put in setenv.sh this settings:

export JAVA_OPTS="-Xms64m -Xmx128m -XX:MaxPermSize=128m"


The heap size start to be ok for my server memory limit:

222444      02:26 25934 /home/keol/java/bin/java
-Djava.util.logging.config.file=/home/keol/webapps/tomcat/conf/logging.properties
-Xms64m -Xmx128m -XX:MaxPermSize=128m
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.endorsed.dirs=/home/keol/webapps/tomcat/endorsed -classpath
/home/keol/webapps/tomcat/bin/bootstrap.jar:/home/keol/webapps/tomcat/bin/tomcat-juli.jar
-Dcatalina.base=/home/keol/webapps/tomcat
-Dcatalina.home=/home/keol/webapps/tomcat
-Djava.io.tmpdir=/home/keol/webapps/tomcat/temp
org.apache.catalina.startup.Bootstrap start



Thanks,

Alfredo



2012/2/14 Alfredo Alessandrini <al...@gmail.com>:
>> Where is that Tomcat from ? how was it installed ? how is it being started ?
>
> I've used this tutorial to install Tomcat:
>
> http://community.webfaction.com/questions/4116/install-tomcat-howto-or-step-by-step-tutorial
>
> It's started with ~/webapps/tomcat/bin/shutdown.sh
>
>
>
> Alfredo
>
>
> 2012/2/14 André Warnier <aw...@ice-sa.com>:
>> Alfredo Alessandrini wrote:
>>>
>>> Hi,
>>>
>>> I'm running tomcat 7.0.25 in a shared server (centOS 64bit).
>>>
>>> Memory limit for my account is 256m.
>>>
>>> I'm running tomcat with this settings:
>>
>>
>> No, you are not. See [1] below.
>>
>>
>>>
>>> export CATALINA_OPTS="-Xms128m -Xmx256m"
>>>
>>> export JAVA_OPTS="-Xms128m -Xmx256m"
>>>
>>> But the process exceed the limit that I've set:
>>>
>>> RSS ELAPSED PID COMMAND
>>> 318340 01:14 37152 /home/keol/java/bin/java
>>>
>>> -Djava.util.logging.config.file=/home/keol/webapps/tomcat/conf/logging.properties
>>
>>
>>> -Xms64m -Xmx128m  [1] <-- this is what you are really running with
>>
>>
>>> -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
>>
>>
>>> -Xms64m -Xmx128m  [1] <-- and this ??
>>
>>
>>> -Djava.endorsed.dirs=/home/keol/webapps/tomcat/endorsed -classpath
>>>
>>> /home/keol/webapps/tomcat/bin/bootstrap.jar:/home/keol/webapps/tomcat/bin/tomcat-juli.jar
>>> -Dcatalina.base=/home/keol/webapps/tomcat
>>> -Dcatalina.home=/home/keol/webapps/tomcat
>>> -Djava.io.tmpdir=/home/keol/webapps/tomcat/temp
>>> org.apache.catalina.startup.Bootstrap start
>>>
>>> There is a way to limit the memory usage?
>>>
>>
>> Item #1 :
>> the -Xms...M and -Xmx...M command-line switches for Java, represent
>> respectively
>> -Xms...M : the number of MB allocated to the Java Heap when Java starts
>> -Xmx...M : the maximum number of MB that Java is allowed to use for the Heap
>>
>> The Heap is only one part of the memory used by the Java process.  You still
>> have to load the Java JVM code, the classes of the application (Tomcat), the
>> classes of your webapps, the JVM stack, etc..
>>  So if you are only allowed to use 256MB in total, my guess would be that
>> you'd better limit the Heap to 64MB or so (maybe 128MB).  Anyway, apart from
>> relatively simple applications, that is not a whole lot for running Tomcat..
>>
>> Item #2:  the parameters which you are specifying in
>>
>>> export CATALINA_OPTS="-Xms128m -Xmx256m"
>>> export JAVA_OPTS="-Xms128m -Xmx256m"
>> are obviously not the ones that the running Tomcat process is using, since
>> it says differently in your "ps" display.
>>
>> Item #3: whatever parameters you are really using, seem to be added 2 times
>> to the Java command-line (see [1] above).
>>
>> So apart from your basic question, there is something wrong in your
>> configuration.
>>
>> Where is that Tomcat from ? how was it installed ? how is it being started ?
>>
>> P.S. I would add that choosing an installation path for Tomcat, which
>> contains "webapps" at a level above the Tomcat installation directory, is
>> maybe not the best choice, if you want to avoid confusion later.
>>
>>
>> ---------------------------------------------------------------------
>> 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: memory heap size

Posted by Alfredo Alessandrini <al...@gmail.com>.
> Where is that Tomcat from ? how was it installed ? how is it being started ?

I've used this tutorial to install Tomcat:

http://community.webfaction.com/questions/4116/install-tomcat-howto-or-step-by-step-tutorial

It's started with ~/webapps/tomcat/bin/shutdown.sh



Alfredo


2012/2/14 André Warnier <aw...@ice-sa.com>:
> Alfredo Alessandrini wrote:
>>
>> Hi,
>>
>> I'm running tomcat 7.0.25 in a shared server (centOS 64bit).
>>
>> Memory limit for my account is 256m.
>>
>> I'm running tomcat with this settings:
>
>
> No, you are not. See [1] below.
>
>
>>
>> export CATALINA_OPTS="-Xms128m -Xmx256m"
>>
>> export JAVA_OPTS="-Xms128m -Xmx256m"
>>
>> But the process exceed the limit that I've set:
>>
>> RSS ELAPSED PID COMMAND
>> 318340 01:14 37152 /home/keol/java/bin/java
>>
>> -Djava.util.logging.config.file=/home/keol/webapps/tomcat/conf/logging.properties
>
>
>> -Xms64m -Xmx128m  [1] <-- this is what you are really running with
>
>
>> -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
>
>
>> -Xms64m -Xmx128m  [1] <-- and this ??
>
>
>> -Djava.endorsed.dirs=/home/keol/webapps/tomcat/endorsed -classpath
>>
>> /home/keol/webapps/tomcat/bin/bootstrap.jar:/home/keol/webapps/tomcat/bin/tomcat-juli.jar
>> -Dcatalina.base=/home/keol/webapps/tomcat
>> -Dcatalina.home=/home/keol/webapps/tomcat
>> -Djava.io.tmpdir=/home/keol/webapps/tomcat/temp
>> org.apache.catalina.startup.Bootstrap start
>>
>> There is a way to limit the memory usage?
>>
>
> Item #1 :
> the -Xms...M and -Xmx...M command-line switches for Java, represent
> respectively
> -Xms...M : the number of MB allocated to the Java Heap when Java starts
> -Xmx...M : the maximum number of MB that Java is allowed to use for the Heap
>
> The Heap is only one part of the memory used by the Java process.  You still
> have to load the Java JVM code, the classes of the application (Tomcat), the
> classes of your webapps, the JVM stack, etc..
>  So if you are only allowed to use 256MB in total, my guess would be that
> you'd better limit the Heap to 64MB or so (maybe 128MB).  Anyway, apart from
> relatively simple applications, that is not a whole lot for running Tomcat..
>
> Item #2:  the parameters which you are specifying in
>
>> export CATALINA_OPTS="-Xms128m -Xmx256m"
>> export JAVA_OPTS="-Xms128m -Xmx256m"
> are obviously not the ones that the running Tomcat process is using, since
> it says differently in your "ps" display.
>
> Item #3: whatever parameters you are really using, seem to be added 2 times
> to the Java command-line (see [1] above).
>
> So apart from your basic question, there is something wrong in your
> configuration.
>
> Where is that Tomcat from ? how was it installed ? how is it being started ?
>
> P.S. I would add that choosing an installation path for Tomcat, which
> contains "webapps" at a level above the Tomcat installation directory, is
> maybe not the best choice, if you want to avoid confusion later.
>
>
> ---------------------------------------------------------------------
> 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: memory heap size

Posted by Ognjen Blagojevic <og...@gmail.com>.
On 14.2.2012 14:55, André Warnier wrote:
> The Heap is only one part of the memory used by the Java process.

Exactly. Here is some more information on the topic:

http://stackoverflow.com/questions/8037920/tomcat-memory-consumption-is-more-than-heap-permgen-space

-Ognjen

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


Re: memory heap size

Posted by André Warnier <aw...@ice-sa.com>.
Alfredo Alessandrini wrote:
> Hi,
> 
> I'm running tomcat 7.0.25 in a shared server (centOS 64bit).
> 
> Memory limit for my account is 256m.
> 
> I'm running tomcat with this settings:

No, you are not. See [1] below.

> 
> export CATALINA_OPTS="-Xms128m -Xmx256m"
> 
> export JAVA_OPTS="-Xms128m -Xmx256m"
> 
> But the process exceed the limit that I've set:
> 
> RSS ELAPSED PID COMMAND
> 318340 01:14 37152 /home/keol/java/bin/java
> -Djava.util.logging.config.file=/home/keol/webapps/tomcat/conf/logging.properties

> -Xms64m -Xmx128m  [1] <-- this is what you are really running with

> -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager

> -Xms64m -Xmx128m  [1] <-- and this ??

> -Djava.endorsed.dirs=/home/keol/webapps/tomcat/endorsed -classpath
> /home/keol/webapps/tomcat/bin/bootstrap.jar:/home/keol/webapps/tomcat/bin/tomcat-juli.jar
> -Dcatalina.base=/home/keol/webapps/tomcat
> -Dcatalina.home=/home/keol/webapps/tomcat
> -Djava.io.tmpdir=/home/keol/webapps/tomcat/temp
> org.apache.catalina.startup.Bootstrap start
> 
> There is a way to limit the memory usage?
> 

Item #1 :
the -Xms...M and -Xmx...M command-line switches for Java, represent respectively
-Xms...M : the number of MB allocated to the Java Heap when Java starts
-Xmx...M : the maximum number of MB that Java is allowed to use for the Heap

The Heap is only one part of the memory used by the Java process.  You still have to load 
the Java JVM code, the classes of the application (Tomcat), the classes of your webapps, 
the JVM stack, etc..
  So if you are only allowed to use 256MB in total, my guess would be that you'd better 
limit the Heap to 64MB or so (maybe 128MB).  Anyway, apart from relatively simple 
applications, that is not a whole lot for running Tomcat..

Item #2:  the parameters which you are specifying in
 > export CATALINA_OPTS="-Xms128m -Xmx256m"
 > export JAVA_OPTS="-Xms128m -Xmx256m"
are obviously not the ones that the running Tomcat process is using, since it says 
differently in your "ps" display.

Item #3: whatever parameters you are really using, seem to be added 2 times to the Java 
command-line (see [1] above).

So apart from your basic question, there is something wrong in your configuration.

Where is that Tomcat from ? how was it installed ? how is it being started ?

P.S. I would add that choosing an installation path for Tomcat, which contains "webapps" 
at a level above the Tomcat installation directory, is maybe not the best choice, if you 
want to avoid confusion later.


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


Re: memory heap size

Posted by Daniel Mikusa <dm...@vmware.com>.
On Tue, 2012-02-14 at 05:07 -0800, Alfredo Alessandrini wrote:
> Hi,
> 
> I'm running tomcat 7.0.25 in a shared server (centOS 64bit).
> 
> Memory limit for my account is 256m.
> 
> I'm running tomcat with this settings:
> 
> export CATALINA_OPTS="-Xms128m -Xmx256m"
> 
> export JAVA_OPTS="-Xms128m -Xmx256m"

1.) You don't need to specify both CATALINA_OPTS and JAVA_OPTS.  Putting
these values into CATALINA_OPTS should be sufficient.

2.) Setting "-Xmx" will set the maximum size for the Java Heap.  This is
different than the total memory used by the OS process.

> 
> But the process exceed the limit that I've set:
> 
> RSS ELAPSED PID COMMAND
> 318340 01:14 37152 /home/keol/java/bin/java
> -Djava.util.logging.config.file=/home/keol/webapps/tomcat/conf/logging.properties
> -Xms64m -Xmx128m
> -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
> -Xms64m -Xmx128m
> -Djava.endorsed.dirs=/home/keol/webapps/tomcat/endorsed -classpath
> /home/keol/webapps/tomcat/bin/bootstrap.jar:/home/keol/webapps/tomcat/bin/tomcat-juli.jar
> -Dcatalina.base=/home/keol/webapps/tomcat
> -Dcatalina.home=/home/keol/webapps/tomcat
> -Djava.io.tmpdir=/home/keol/webapps/tomcat/temp
> org.apache.catalina.startup.Bootstrap start
> 
> There is a way to limit the memory usage?

The total size of the Java OS process consists a few different elements.

 1.) the Java Heap
 2.) PermGen Space
 3.) Thread Stacks
 4.) Some other minor things

You can limit the first with "-Xmx" and the second with
"-XX:MaxPermSize".  You can't limit the overall thread stack size, but
you can lower the per thread stack size with "-Xss".

Off the top of my head, that's all I can think of for limiting the JVM.
However, you may have one other option.  If your OS supports a way to
limit the amount of memory available to a process, you could try that as
well. 

Dan