You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by dOE <do...@gmail.com> on 2009/03/04 03:11:19 UTC

How to set Java Memory heap size on Linux?

Tomct 6.0
Red Hat EL 4

How can I set the Java Memory heap for Tomcat?

I know in Windows this is done through the Registry adding -Xms256m
-Xmx768m.
>From what I have read on the internet to do the same on a Linux system I
need to add the following line to my ../tomcat/bin/catalina.sh fle?

JAVA_OPTS=-Xms256m -Xmx768m

If this is in fact the case?  ...then does it matter where in the file the
line is inserted?

Re: How to set Java Memory heap size on Linux?

Posted by zhaoxueqing <zh...@g-data.com.cn>.
in tomcat/bin/catalina.sh
add a parameter into this file
export JAVA_OPTS=-Xmx512m



----- Original Message ----- 
From: "dOE" <do...@gmail.com>
To: "Tomcat User-List" <us...@tomcat.apache.org>
Sent: Wednesday, March 04, 2009 10:11 AM
Subject: How to set Java Memory heap size on Linux?


> Tomct 6.0
> Red Hat EL 4
> 
> How can I set the Java Memory heap for Tomcat?
> 
> I know in Windows this is done through the Registry adding -Xms256m
> -Xmx768m.
> From what I have read on the internet to do the same on a Linux system I
> need to add the following line to my ../tomcat/bin/catalina.sh fle?
> 
> JAVA_OPTS=-Xms256m -Xmx768m
> 
> If this is in fact the case?  ...then does it matter where in the file the
> line is inserted?
>

Re: How to set Java Memory heap size on Linux?

Posted by Rainer Jung <ra...@kippdata.de>.
On 09.03.2009 19:30, Caldarale, Charles R wrote:
>> From: dOE [mailto:doepain@gmail.com]
>> Subject: Re: How to set Java Memory heap size on Linux?
>>
>> What is the syntax of the "setenv.sh script"?
>
> It's whatever syntax your shell supports.  The export command is often needed for Linux shells.

The script setenv.sh is not being executed with its own shell, it gets 
sourced into catalina.sh:

if [ -r "$CATALINA_BASE"/bin/setenv.sh ]; then
   . "$CATALINA_BASE"/bin/setenv.sh
elif [ -r "$CATALINA_HOME"/bin/setenv.sh ]; then
   . "$CATALINA_HOME"/bin/setenv.sh
fi

So it runs in the same shell as catalina.sh and therefore you don't need 
to export those variables, which are only used inside catalina.sh.

By default catalina.sh gets executed by /bin/sh, since its first line is:

    #!/bin/sh

Regards,

Rainer

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


RE: How to set Java Memory heap size on Linux?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: dOE [mailto:doepain@gmail.com] 
> Subject: Re: How to set Java Memory heap size on Linux?
> 
> What is the syntax of the "setenv.sh script"?

It's whatever syntax your shell supports.  The export command is often needed for Linux shells.

 - 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: How to set Java Memory heap size on Linux?

Posted by dOE <do...@gmail.com>.
What is the syntax of the "setenv.sh script"?  Is it just line by line
setting environmental variables?
JAVA_OPTS=-Xms256m -Xmx768m
CATALINA_OPTS=

I am correct in assuming this is all I would need to populate the file with?


On Wed, Mar 4, 2009 at 12:26 AM, Caldarale, Charles R <
Chuck.Caldarale@unisys.com> wrote:

> > From: dOE [mailto:doepain@gmail.com]
> > Subject: How to set Java Memory heap size on Linux?
> >
> > I know in Windows this is done through the Registry
> > adding -Xms256m -Xmx768m.
>
> You should not be editing the registry in Windows; use the tomcat6w.exe
> program to manipulate the various JVM parameters when running Tomcat as a
> Windows service.
>
> > From what I have read on the internet to do the same
> > on a Linux system I need to add the following line to
> > my ../tomcat/bin/catalina.sh fle?
> > JAVA_OPTS=-Xms256m -Xmx768m
>
> Also incorrect, but that's a widely-held belief (as evidenced by the answer
> from zhaoxueqing).  What you should actually do is create a setenv.sh script
> in Tomcat's bin directory that establishes any environment variables you
> need, including JAVA_OPTS (CATALINA_OPTS is actually preferable here).  The
> Tomcat startup scripts automatically call setenv.sh if it exists; this
> avoids having to modify Tomcat-supplied scripts.
>
>  - 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: How to set Java Memory heap size on Linux?

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: dOE [mailto:doepain@gmail.com]
> Subject: How to set Java Memory heap size on Linux?
>
> I know in Windows this is done through the Registry
> adding -Xms256m -Xmx768m.

You should not be editing the registry in Windows; use the tomcat6w.exe program to manipulate the various JVM parameters when running Tomcat as a Windows service.

> From what I have read on the internet to do the same
> on a Linux system I need to add the following line to
> my ../tomcat/bin/catalina.sh fle?
> JAVA_OPTS=-Xms256m -Xmx768m

Also incorrect, but that's a widely-held belief (as evidenced by the answer from zhaoxueqing).  What you should actually do is create a setenv.sh script in Tomcat's bin directory that establishes any environment variables you need, including JAVA_OPTS (CATALINA_OPTS is actually preferable here).  The Tomcat startup scripts automatically call setenv.sh if it exists; this avoids having to modify Tomcat-supplied scripts.

 - 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