You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by V Jayakumar <vj...@hotmail.com> on 2010/01/08 10:43:31 UTC

Max heap size

Hello

 

OS : 32 Bit Redt Hat Enterprise Linux

 

$ java -version
java version "1.6.0_14"
Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)

 

apache-tomcat-5.5.20 

 

Server has 4 GB of RAM.

 

What is the maximum value that can be passed to  -Xmx ?

 

Thanks in advance for the help.
 		 	   		  
_________________________________________________________________
Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010

Re: Max heap size

Posted by Robin Wilson <rw...@kingsisle.com>.
We're running with -Xmx=6g right now. No problems. 64-bit RHEL  
platform, so you may need a 64-bit OS for that.

--
Robin D. Wilson



On Jan 10, 2010, at 8:59 AM, "V Jayakumar" <vj...@hotmail.com> wrote:

>
> All
>
>
>
> Thank you all for the replies & the scripts.
>
>
>
> It is true that we can find the results through tests.
>
>
>
> http://docs.sun.com/app/docs/doc/819-3681/abeii?a=view
>
>
> says that maximum address space for a process in 32 bit version of  
> Linux is 2 GB.
>
>
>
> But am not sure for which version of JRE this limitation is  
> applicable.
>
>
>
> In particular, I expect JRE 1.6 will be able to address more than 2  
> GB of space.
>
>
>
> In our environment we start Tomcat through  
> org.apache.catalina.startup.Bootstrap
>
>
>
> Before we try our tests with different values for Xmx woud like to  
> know, if anyone had tried tomcat with higher values for Xmx.
>
>
>
> Thanks
>
>
>
>
>
>> Date: Fri, 8 Jan 2010 16:00:43 -0500
>> From: chris@christopherschultz.net
>> To: users@tomcat.apache.org
>> Subject: Re: Max heap size
>>
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA1
>>
>> Chuck,
>>
>> On 1/8/2010 3:34 PM, Caldarale, Charles R wrote:
>>>> From: Christopher Schultz [mailto:chris@christopherschultz.net]
>>>> Subject: Re: Max heap size
>>>>
>>>> Here's an updated script to check for maximum heap.
>>>
>>> Just remember that this measures the maximum heap available to an
>>> extremely simple process. For a complex execution like Tomcat or  
>>> some
>>> other app server, the amount of space needed for non-heap structures
>>> (e.g., open file descriptions, additional native libraries, stacks)
>>> might have to be traded off against the Java heap.
>>
>> Fair enough, but I don't believe the JVM checks the "size" of the  
>> code
>> to be run before deciding if it can launch the JVM: it will simply
>> attempt to allocate the memory you request and then launch your  
>> main method.
>>
>> Had I used org.apache.catalina.Bootstrap as the main class within the
>> same script, I suspect I would have gotten the same results for my
>> maximum heap test.
>>
>> There's nothing to say that the JVM wouldn't shut down after some  
>> time
>> because it ran out of native heap, etc. but I don't think the size of
>> the test case here is all that relevant.
>>
>> - -chris
>> -----BEGIN PGP SIGNATURE-----
>> Version: GnuPG v1.4.10 (MingW32)
>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>>
>> iEYEARECAAYFAktHnPsACgkQ9CaO5/Lv0PBH8gCfURoUAUZ5qSF2mD8qg45jJnOH
>> twsAn2bBKC46vDLaWdYbVTmm5CrqfdUI
>> =Pu6U
>> -----END PGP SIGNATURE-----
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>
> _________________________________________________________________
> Windows Live Hotmail: Your friends can get your Facebook updates,  
> right from HotmailĀ®.
> http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009

RE: Max heap size

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: V Jayakumar [mailto:vjk@hotmail.com]
> Subject: RE: Max heap size
> 
> http://docs.sun.com/app/docs/doc/819-3681/abeii?a=view
>  says that maximum address space for a process in 32 bit version of
> Linux is 2 GB.
> 
> But am not sure for which version of JRE this limitation is applicable.

Again, the limit is not related to the JRE you're using - it's imposed by the OS.  Some versions of 32-bit Linux and Windows allow you to configure a 3 GB process space, although the default usually is 2 GB.  Also again, the only way you're going to find out what the heap limit is for your environment is to experiment.  You've been given more than enough tools and techniques to do so, so do it.

 - 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: Max heap size

Posted by V Jayakumar <vj...@hotmail.com>.
All

 

Thank you all for the replies & the scripts.

 

It is true that we can find the results through tests. 

 

http://docs.sun.com/app/docs/doc/819-3681/abeii?a=view
 

 says that maximum address space for a process in 32 bit version of Linux is 2 GB.

 

But am not sure for which version of JRE this limitation is applicable.

 

In particular, I expect JRE 1.6 will be able to address more than 2 GB of space.

 

In our environment we start Tomcat through org.apache.catalina.startup.Bootstrap

 

Before we try our tests with different values for Xmx woud like to know, if anyone had tried tomcat with higher values for Xmx.

 

Thanks

 


 
> Date: Fri, 8 Jan 2010 16:00:43 -0500
> From: chris@christopherschultz.net
> To: users@tomcat.apache.org
> Subject: Re: Max heap size
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Chuck,
> 
> On 1/8/2010 3:34 PM, Caldarale, Charles R wrote:
> >> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> >> Subject: Re: Max heap size
> >>
> >> Here's an updated script to check for maximum heap.
> > 
> > Just remember that this measures the maximum heap available to an
> > extremely simple process. For a complex execution like Tomcat or some
> > other app server, the amount of space needed for non-heap structures
> > (e.g., open file descriptions, additional native libraries, stacks)
> > might have to be traded off against the Java heap.
> 
> Fair enough, but I don't believe the JVM checks the "size" of the code
> to be run before deciding if it can launch the JVM: it will simply
> attempt to allocate the memory you request and then launch your main method.
> 
> Had I used org.apache.catalina.Bootstrap as the main class within the
> same script, I suspect I would have gotten the same results for my
> maximum heap test.
> 
> There's nothing to say that the JVM wouldn't shut down after some time
> because it ran out of native heap, etc. but I don't think the size of
> the test case here is all that relevant.
> 
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> 
> iEYEARECAAYFAktHnPsACgkQ9CaO5/Lv0PBH8gCfURoUAUZ5qSF2mD8qg45jJnOH
> twsAn2bBKC46vDLaWdYbVTmm5CrqfdUI
> =Pu6U
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
 		 	   		  
_________________________________________________________________
Windows Live Hotmail: Your friends can get your Facebook updates, right from HotmailĀ®.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009

Re: Max heap size

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

Chuck,

On 1/8/2010 3:34 PM, Caldarale, Charles R wrote:
>> From: Christopher Schultz [mailto:chris@christopherschultz.net]
>> Subject: Re: Max heap size
>>
>> Here's an updated script to check for maximum heap.
> 
> Just remember that this measures the maximum heap available to an
> extremely simple process. For a complex execution like Tomcat or some
> other app server, the amount of space needed for non-heap structures
> (e.g., open file descriptions, additional native libraries, stacks)
> might have to be traded off against the Java heap.

Fair enough, but I don't believe the JVM checks the "size" of the code
to be run before deciding if it can launch the JVM: it will simply
attempt to allocate the memory you request and then launch your main method.

Had I used org.apache.catalina.Bootstrap as the main class within the
same script, I suspect I would have gotten the same results for my
maximum heap test.

There's nothing to say that the JVM wouldn't shut down after some time
because it ran out of native heap, etc. but I don't think the size of
the test case here is all that relevant.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAktHnPsACgkQ9CaO5/Lv0PBH8gCfURoUAUZ5qSF2mD8qg45jJnOH
twsAn2bBKC46vDLaWdYbVTmm5CrqfdUI
=Pu6U
-----END PGP SIGNATURE-----

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


RE: Max heap size

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Christopher Schultz [mailto:chris@christopherschultz.net]
> Subject: Re: Max heap size
> 
> Here's an updated script to check for maximum heap.

Just remember that this measures the maximum heap available to an extremely simple process.  For a complex execution like Tomcat or some other app server, the amount of space needed for non-heap structures (e.g., open file descriptions, additional native libraries, stacks) might have to be traded off against the Java heap.

 - 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.



Re: Max heap size

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

All,

Here's an updated script to check for maximum heap. I'm also including
the (simple) code for the MemoryInfo class referenced in the script (the
lack of this class being available was why the script failed for me
earlier).

Enjoy,
- -chris

maxheap.sh
- ----------
#!/bin/sh
#
# Set JAVA_OPTS to "-server" if you want to use the server JVM.
# Please don't set JAVA_OPTS to include either -Xms or -Xmx.
#

initial_max=${1:-4096}

max=${initial_max}
return_value=1

echo -n Working...

while [ "1" = "$return_value" -a "0" -lt "$max" ] ; do
  if [ "0" == `expr ${max} % 100` ] ; then
    echo
    echo -n "Still working (currently checking ${max}M)..."
  fi
  output=`java -showversion $JAVA_OPTS -Xms${max}M -Xmx${max}M
MemoryInfo 2>&1`

  return_value=$?

  if [ "1" = "$return_value" ] ; then
    max=`expr ${max} - 1`
  fi
done

echo

if [ "0" = "$max" ] ; then
  echo "No maximum heap size found. :("
else
  echo Stopped with max=${max}
  echo Return value was ${return_value}
  echo Memory Info is:
  echo "$output"
fi


MemoryInfo.java
- ---------------
public class MemoryInfo
{
    public static void main(String[] args)
    {
        Runtime rt = Runtime.getRuntime();
        System.out.printf("total=%10db (%4dMiB)", rt.totalMemory(),
(rt.totalMemory() / (1024*1024)));
        System.out.println();
        System.out.printf("  max=%10db (%4dMiB)", rt.maxMemory(),
(rt.maxMemory() / (1024*1024)));
        System.out.println();
        System.out.printf(" free=%10db (%4dMiB)", rt.freeMemory(),
(rt.freeMemory() / (1024*1024)));
        System.out.println();
    }
}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAktHlKgACgkQ9CaO5/Lv0PBdyQCgoHFQ+PyvOKBLtHaEC7mi712G
poQAn1rfxwUfJBEn4D69zivzsZCHrG4h
=2oyq
-----END PGP SIGNATURE-----

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


Re: Max heap size

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

Chuck,

On 1/8/2010 9:37 AM, Caldarale, Charles R wrote:
> Experimenting to find the largest -Xmx value for your environment
> should only take a few minutes.

I used this script long ago and got something like 2600 MiB as the max I
could use. I just tried it (moved to a VM recently) and it never
returned a valid max heap. Something might be wrong with the script or
the (hardware) VM configuration.

#!/bin/sh

initial_max=4097

max=${initial_max}
return_value=1

while [ "1" == "$return_value" ] ; do
  max=`expr ${max} - 1`

  if [ "0" == `expr ${max} % 100` ] ; then
    echo "(max=${max})"
  fi
  java -Xms${max}M -Xmx${max}M MemoryInfo > /dev/null 2>&1

  return_value=$?
done

echo
echo Stopped with max=${max}
echo Return value was ${return_value}
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAktHXPAACgkQ9CaO5/Lv0PB9LACfeMPE0r2+F32dNX8iOb2zsnSK
kA0AnApF0JsenFvK58yqrd5AQBn54ToK
=LM48
-----END PGP SIGNATURE-----

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


RE: Max heap size

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: V Jayakumar [mailto:vjk@hotmail.com]
> Subject: Max heap size
> 
> OS : 32 Bit Redt Hat Enterprise Linux
> $ java -version
> java version "1.6.0_14"
> Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
> Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)
> apache-tomcat-5.5.20

Useful information.

> Server has 4 GB of RAM.

Not relevant for -Xmx, but is relevant for system performance.

> What is the maximum value that can be passed to  -Xmx ?

You will need to experiment to determine the exact value, and that may change with JVM updates, Linux patches, file usage, etc.  On a 32-bit OS, virtual process space is either 2 or 3 GB, and the Java heap as well as numerous other memory consumers must fit inside that space.  The RAM size has nothing to do with the heap size, but you should insure that the sum of *all* real process spaces that are active does not exceed the available RAM, or you may start to incur page thrashing.

Experimenting to find the largest -Xmx value for your environment should only take a few minutes.

 - 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: Max heap size

Posted by Paolo Santarsiero <pa...@gmail.com>.
Well, it depends on the jvm memory usage. I use for my system this JAVA_HOME
jvm parameters in catalina.sh:
 -Xms64m -Xmx512m -XX:MaxPermSize=200m
It is not certain that this configuration is good for your system. I set
200Mb for max permgen size because the objects in permgen on average occupy
120Mb, but might be too much or too little for you. The same is true for
-Xms and -Xmx
I suggest you monitor your heap first (by jconsole or jvisualvm), in order
to know  memory usage by applications, and only then optimize the
configuration.


2010/1/8 V Jayakumar <vj...@hotmail.com>

>
> Hello
>
>
>
> OS : 32 Bit Redt Hat Enterprise Linux
>
>
>
> $ java -version
> java version "1.6.0_14"
> Java(TM) SE Runtime Environment (build 1.6.0_14-b08)
> Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)
>
>
>
> apache-tomcat-5.5.20
>
>
>
> Server has 4 GB of RAM.
>
>
>
> What is the maximum value that can be passed to  -Xmx ?
>
>
>
> Thanks in advance for the help.
>
> _________________________________________________________________
> Windows Live: Friends get your Flickr, Yelp, and Digg updates when they
> e-mail you.
>
> http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010