FAQ
I run Linux/Apache/Tomcat plus Oracle on a server with 512Mb of memory. I
have successfully implemented a couple of Internet applications using JSP,
Servlets (plus Oracle) etc.

For each application (and client) I start a new Tomcat session, using a
custom server.xml for each one. All was ok, until I tried increasing Tomcat
sessions from 6 to 7, then I received the java.lang.OutOfMemoryError when
starting the Tomcat sessions.

I've read through many of the posts on this subject, some of which suggest
to increase the "heap" size. Unfortunately, I'm a newbie to Java (and Linux
and JSP and Oracle <g>) so I don't know how to either check this heap size,
nor how to permanently set it to a value via a script using a switch
like -Xms256m.

The script I use to start Tomcat follows, plus the console output. Could
anyone advise how to set the heap please?


Many thanks,

Max Hugen maxhugen@hugen.com.au
Hugen Enterprises Pty Ltd, Sydney, Australia
www.hugen.com.au
Internet Application Developers
Script Start>>>>>>>>
echo "~~~~~~~~Tomcat Startup ~~~~~~~~~~~~~"
echo "Start an instance of Tomcat for hugen"
/usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_he.xml
echo "Start an instance of Tomcat for yass3i"
/usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_yass3i.xml
echo "Start an instance of Tomcat for isp"
/usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_isp.xml
echo "Start an instance of Tomcat for im2000i"
/usr/local/tomcat/bin/startup.sh -f
/usr/local/tomcat/conf/server_im2000i.xml
echo "Start an instance of Tomcat for secure"
/usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_secure.xml
echo "Start an instance of Tomcat for aedo"
/usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_aedo.xml
echo "Start an instance of Tomcat for ncap"
/usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_ncap.xml
# Give Tomcat time to start before restarting Apache.
echo "Waiting 45 secs..."
sleep 45
# Restart Apache to register Tomcat properly.
echo "Restart Apache"
/etc/rc.d/init.d/httpd stop
/etc/rc.d/init.d/httpd start
sleep 2
echo "Ok, we should be in business!"
Script End>>>>>>>>
Console Output Start>>>>>>>>
Starting tomcat. Check logs/tomcat.log for error messages
Starting tomcat. Check logs/tomcat.log for error messages
Starting tomcat. Check logs/tomcat.log for error messages
Starting tomcat. Check logs/tomcat.log for error messages
Starting tomcat. Check logs/tomcat.log for error messages
Starting tomcat. Check logs/tomcat.log for error messages
Starting tomcat. Check logs/tomcat.log for error messages

Restart Apache

Exception in thread "main" java.lang.OutOfMemoryError: unable to create new
native thread
at java.lang.Thread.start(Native Method)
at
org.apache.tomcat.util.ThreadPool$ControlRunnable.<init>(ThreadPool.java:465
)
at
org.apache.tomcat.util.ThreadPool.openThreads(ThreadPool.java:360)
at org.apache.tomcat.util.ThreadPool.start(ThreadPool.java:148)
at
org.apache.tomcat.service.PoolTcpEndpoint.startEndpoint(PoolTcpEndpoint.java
:245)
at
org.apache.tomcat.service.PoolTcpConnector.start(PoolTcpConnector.java:188)
at
org.apache.tomcat.core.ContextManager.start(ContextManager.java:527)
at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:202)
at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)

Exception in thread "main" java.lang.OutOfMemoryError: unable to create new
native thread
at java.lang.Thread.start(Native Method)
at
org.apache.tomcat.util.ThreadPool$MonitorRunnable.<init>(ThreadPool.java:382
)
at org.apache.tomcat.util.ThreadPool.start(ThreadPool.java:149)
at
org.apache.tomcat.service.PoolTcpEndpoint.startEndpoint(PoolTcpEndpoint.java
:245)
at
org.apache.tomcat.service.PoolTcpConnector.start(PoolTcpConnector.java:188)
at
org.apache.tomcat.core.ContextManager.start(ContextManager.java:527)
at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:202)
at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)

Shutting down Web Service: httpd

/etc/rc.d/init.d/httpd: fork: Resource temporarily unavailable
Web Service: /usr/sbin/httpd
Console Output End>>>>>>>>
reply

Search Discussions

  • Craig McClanahan at Aug 25, 2001 at 3:47 am
    The "java" command line option you want is actually "-Xmx256m" to set the
    maximum heap size. To set this, you can establish an environment variable
    named TOMCAT_OPTS (Tomcat 3.x) or CATALINA_OPTS (Tomcat 4.x) that contains
    the command line options to be sent to the JVM. For example:

    export TOMCAT_OPTS="-Xmx256m"
    $TOMCAT_HOME/bin/tomcat.sh start

    Craig McClanahan

    On Sat, 25 Aug 2001, Max Hugen wrote:

    Date: Sat, 25 Aug 2001 13:00:41 +1000
    From: Max Hugen <maxhugen@hugen.com.au>
    Reply-To: tomcat-user@jakarta.apache.org, Max Hugen <maxhugen@hugen.com.au>
    To: Tomcat Users List <tomcat-user@jakarta.apache.org>
    Subject: OutOfMemory - Set Java Heap Size?

    I run Linux/Apache/Tomcat plus Oracle on a server with 512Mb of memory. I
    have successfully implemented a couple of Internet applications using JSP,
    Servlets (plus Oracle) etc.

    For each application (and client) I start a new Tomcat session, using a
    custom server.xml for each one. All was ok, until I tried increasing Tomcat
    sessions from 6 to 7, then I received the java.lang.OutOfMemoryError when
    starting the Tomcat sessions.

    I've read through many of the posts on this subject, some of which suggest
    to increase the "heap" size. Unfortunately, I'm a newbie to Java (and Linux
    and JSP and Oracle <g>) so I don't know how to either check this heap size,
    nor how to permanently set it to a value via a script using a switch
    like -Xms256m.

    The script I use to start Tomcat follows, plus the console output. Could
    anyone advise how to set the heap please?


    Many thanks,

    Max Hugen maxhugen@hugen.com.au
    Hugen Enterprises Pty Ltd, Sydney, Australia
    www.hugen.com.au
    Internet Application Developers
    Script Start>>>>>>>>
    echo "~~~~~~~~Tomcat Startup ~~~~~~~~~~~~~"
    echo "Start an instance of Tomcat for hugen"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_he.xml
    echo "Start an instance of Tomcat for yass3i"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_yass3i.xml
    echo "Start an instance of Tomcat for isp"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_isp.xml
    echo "Start an instance of Tomcat for im2000i"
    /usr/local/tomcat/bin/startup.sh -f
    /usr/local/tomcat/conf/server_im2000i.xml
    echo "Start an instance of Tomcat for secure"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_secure.xml
    echo "Start an instance of Tomcat for aedo"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_aedo.xml
    echo "Start an instance of Tomcat for ncap"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_ncap.xml
    # Give Tomcat time to start before restarting Apache.
    echo "Waiting 45 secs..."
    sleep 45
    # Restart Apache to register Tomcat properly.
    echo "Restart Apache"
    /etc/rc.d/init.d/httpd stop
    /etc/rc.d/init.d/httpd start
    sleep 2
    echo "Ok, we should be in business!"
    Script End>>>>>>>>
    Console Output Start>>>>>>>>
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages

    Restart Apache

    Exception in thread "main" java.lang.OutOfMemoryError: unable to create new
    native thread
    at java.lang.Thread.start(Native Method)
    at
    org.apache.tomcat.util.ThreadPool$ControlRunnable.<init>(ThreadPool.java:465
    )
    at
    org.apache.tomcat.util.ThreadPool.openThreads(ThreadPool.java:360)
    at org.apache.tomcat.util.ThreadPool.start(ThreadPool.java:148)
    at
    org.apache.tomcat.service.PoolTcpEndpoint.startEndpoint(PoolTcpEndpoint.java
    :245)
    at
    org.apache.tomcat.service.PoolTcpConnector.start(PoolTcpConnector.java:188)
    at
    org.apache.tomcat.core.ContextManager.start(ContextManager.java:527)
    at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:202)
    at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)

    Exception in thread "main" java.lang.OutOfMemoryError: unable to create new
    native thread
    at java.lang.Thread.start(Native Method)
    at
    org.apache.tomcat.util.ThreadPool$MonitorRunnable.<init>(ThreadPool.java:382
    )
    at org.apache.tomcat.util.ThreadPool.start(ThreadPool.java:149)
    at
    org.apache.tomcat.service.PoolTcpEndpoint.startEndpoint(PoolTcpEndpoint.java
    :245)
    at
    org.apache.tomcat.service.PoolTcpConnector.start(PoolTcpConnector.java:188)
    at
    org.apache.tomcat.core.ContextManager.start(ContextManager.java:527)
    at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:202)
    at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)

    Shutting down Web Service: httpd

    /etc/rc.d/init.d/httpd: fork: Resource temporarily unavailable
    Web Service: /usr/sbin/httpd
    Console Output End>>>>>>>>
  • Aravind Naidu at Aug 25, 2001 at 5:03 am
    You can use "-Xms128m -Xmx256m" which means the heap will start at 128m and
    grow to 256m, but you are better off testing your app first (use verboseGC)
    to check the memory usage and then setting both parameters to the same no.
    (i.e.) "-Xms256m -Xmx256m" or to a value suitable to your app usage and you
    will avoid a delay when the copy occurs after the intial setting.

    I would also suggest that you need to tune up your process, file, inode
    limits at the OS front. If you are going to run 7 instances of Tomcat on a
    512mb machine, you will run out of these fast.

    If you are running 2.2.x kernel series, it is a wee bit more complicated.
    2.4.x series, you are better off.

    Plenty of stuff on the web on this, but a good point to start is
    http://people.redhat.com/alikins/system_tuning.html

    -- Aravind


    -----Original Message-----
    From: craigmcc@mail1.eha.net On Behalf Of
    Craig R. McClanahan
    Sent: Saturday, 25 August 2001 11:42
    To: Tomcat Users List; Max Hugen
    Subject: Re: OutOfMemory - Set Java Heap Size?


    The "java" command line option you want is actually "-Xmx256m" to set the
    maximum heap size. To set this, you can establish an environment variable
    named TOMCAT_OPTS (Tomcat 3.x) or CATALINA_OPTS (Tomcat 4.x) that contains
    the command line options to be sent to the JVM. For example:

    export TOMCAT_OPTS="-Xmx256m"
    $TOMCAT_HOME/bin/tomcat.sh start

    Craig McClanahan

    On Sat, 25 Aug 2001, Max Hugen wrote:

    Date: Sat, 25 Aug 2001 13:00:41 +1000
    From: Max Hugen <maxhugen@hugen.com.au>
    Reply-To: tomcat-user@jakarta.apache.org, Max Hugen
    <maxhugen@hugen.com.au>
    To: Tomcat Users List <tomcat-user@jakarta.apache.org>
    Subject: OutOfMemory - Set Java Heap Size?

    I run Linux/Apache/Tomcat plus Oracle on a server with 512Mb of memory. I
    have successfully implemented a couple of Internet applications using JSP,
    Servlets (plus Oracle) etc.

    For each application (and client) I start a new Tomcat session, using a
    custom server.xml for each one. All was ok, until I tried increasing Tomcat
    sessions from 6 to 7, then I received the java.lang.OutOfMemoryError when
    starting the Tomcat sessions.

    I've read through many of the posts on this subject, some of which suggest
    to increase the "heap" size. Unfortunately, I'm a newbie to Java (and Linux
    and JSP and Oracle <g>) so I don't know how to either check this heap size,
    nor how to permanently set it to a value via a script using a switch
    like -Xms256m.

    The script I use to start Tomcat follows, plus the console output. Could
    anyone advise how to set the heap please?


    Many thanks,

    Max Hugen maxhugen@hugen.com.au
    Hugen Enterprises Pty Ltd, Sydney, Australia
    www.hugen.com.au
    Internet Application Developers
    Script Start>>>>>>>>
    echo "~~~~~~~~Tomcat Startup ~~~~~~~~~~~~~"
    echo "Start an instance of Tomcat for hugen"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_he.xml
    echo "Start an instance of Tomcat for yass3i"
    /usr/local/tomcat/bin/startup.sh -f
    /usr/local/tomcat/conf/server_yass3i.xml
    echo "Start an instance of Tomcat for isp"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_isp.xml
    echo "Start an instance of Tomcat for im2000i"
    /usr/local/tomcat/bin/startup.sh -f
    /usr/local/tomcat/conf/server_im2000i.xml
    echo "Start an instance of Tomcat for secure"
    /usr/local/tomcat/bin/startup.sh -f
    /usr/local/tomcat/conf/server_secure.xml
    echo "Start an instance of Tomcat for aedo"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_aedo.xml
    echo "Start an instance of Tomcat for ncap"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_ncap.xml
    # Give Tomcat time to start before restarting Apache.
    echo "Waiting 45 secs..."
    sleep 45
    # Restart Apache to register Tomcat properly.
    echo "Restart Apache"
    /etc/rc.d/init.d/httpd stop
    /etc/rc.d/init.d/httpd start
    sleep 2
    echo "Ok, we should be in business!"
    Script End>>>>>>>>
    Console Output Start>>>>>>>>
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages

    Restart Apache

    Exception in thread "main" java.lang.OutOfMemoryError: unable to create new
    native thread
    at java.lang.Thread.start(Native Method)
    at
    org.apache.tomcat.util.ThreadPool$ControlRunnable.<init>(ThreadPool.java:465
    )
    at
    org.apache.tomcat.util.ThreadPool.openThreads(ThreadPool.java:360)
    at org.apache.tomcat.util.ThreadPool.start(ThreadPool.java:148)
    at
    org.apache.tomcat.service.PoolTcpEndpoint.startEndpoint(PoolTcpEndpoint.java
    :245)
    at
    org.apache.tomcat.service.PoolTcpConnector.start(PoolTcpConnector.java:188)
    at
    org.apache.tomcat.core.ContextManager.start(ContextManager.java:527)
    at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:202)
    at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)

    Exception in thread "main" java.lang.OutOfMemoryError: unable to create new
    native thread
    at java.lang.Thread.start(Native Method)
    at
    org.apache.tomcat.util.ThreadPool$MonitorRunnable.<init>(ThreadPool.java:382
    )
    at org.apache.tomcat.util.ThreadPool.start(ThreadPool.java:149)
    at
    org.apache.tomcat.service.PoolTcpEndpoint.startEndpoint(PoolTcpEndpoint.java
    :245)
    at
    org.apache.tomcat.service.PoolTcpConnector.start(PoolTcpConnector.java:188)
    at
    org.apache.tomcat.core.ContextManager.start(ContextManager.java:527)
    at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:202)
    at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)

    Shutting down Web Service: httpd

    /etc/rc.d/init.d/httpd: fork: Resource temporarily unavailable
    Web Service: /usr/sbin/httpd
    Console Output End>>>>>>>>
  • Barnabas Yohannes at Aug 27, 2001 at 3:53 pm
    Where is this command line to set the maximum heap size located? Please
    help, I am kind of new to this staff!

    ----- Original Message -----
    From: "Craig R. McClanahan" <craigmcc@apache.org>
    To: "Tomcat Users List" <tomcat-user@jakarta.apache.org>; "Max Hugen"
    <maxhugen@hugen.com.au>
    Sent: Friday, August 24, 2001 10:41 PM
    Subject: Re: OutOfMemory - Set Java Heap Size?

    The "java" command line option you want is actually "-Xmx256m" to set the
    maximum heap size. To set this, you can establish an environment variable
    named TOMCAT_OPTS (Tomcat 3.x) or CATALINA_OPTS (Tomcat 4.x) that contains
    the command line options to be sent to the JVM. For example:

    export TOMCAT_OPTS="-Xmx256m"
    $TOMCAT_HOME/bin/tomcat.sh start

    Craig McClanahan

    On Sat, 25 Aug 2001, Max Hugen wrote:

    Date: Sat, 25 Aug 2001 13:00:41 +1000
    From: Max Hugen <maxhugen@hugen.com.au>
    Reply-To: tomcat-user@jakarta.apache.org, Max Hugen
    <maxhugen@hugen.com.au>
    To: Tomcat Users List <tomcat-user@jakarta.apache.org>
    Subject: OutOfMemory - Set Java Heap Size?

    I run Linux/Apache/Tomcat plus Oracle on a server with 512Mb of memory.
    I
    have successfully implemented a couple of Internet applications using
    JSP,
    Servlets (plus Oracle) etc.

    For each application (and client) I start a new Tomcat session, using a
    custom server.xml for each one. All was ok, until I tried increasing
    Tomcat
    sessions from 6 to 7, then I received the java.lang.OutOfMemoryError
    when
    starting the Tomcat sessions.

    I've read through many of the posts on this subject, some of which
    suggest
    to increase the "heap" size. Unfortunately, I'm a newbie to Java (and
    Linux
    and JSP and Oracle <g>) so I don't know how to either check this heap
    size,
    nor how to permanently set it to a value via a script using a switch
    like -Xms256m.

    The script I use to start Tomcat follows, plus the console output. Could
    anyone advise how to set the heap please?


    Many thanks,

    Max Hugen maxhugen@hugen.com.au
    Hugen Enterprises Pty Ltd, Sydney, Australia
    www.hugen.com.au
    Internet Application Developers
    Script Start>>>>>>>>
    echo "~~~~~~~~Tomcat Startup ~~~~~~~~~~~~~"
    echo "Start an instance of Tomcat for hugen"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_he.xml
    echo "Start an instance of Tomcat for yass3i"
    /usr/local/tomcat/bin/startup.sh -f
    /usr/local/tomcat/conf/server_yass3i.xml
    echo "Start an instance of Tomcat for isp"
    /usr/local/tomcat/bin/startup.sh -f
    /usr/local/tomcat/conf/server_isp.xml
    echo "Start an instance of Tomcat for im2000i"
    /usr/local/tomcat/bin/startup.sh -f
    /usr/local/tomcat/conf/server_im2000i.xml
    echo "Start an instance of Tomcat for secure"
    /usr/local/tomcat/bin/startup.sh -f
    /usr/local/tomcat/conf/server_secure.xml
    echo "Start an instance of Tomcat for aedo"
    /usr/local/tomcat/bin/startup.sh -f
    /usr/local/tomcat/conf/server_aedo.xml
    echo "Start an instance of Tomcat for ncap"
    /usr/local/tomcat/bin/startup.sh -f
    /usr/local/tomcat/conf/server_ncap.xml
    # Give Tomcat time to start before restarting Apache.
    echo "Waiting 45 secs..."
    sleep 45
    # Restart Apache to register Tomcat properly.
    echo "Restart Apache"
    /etc/rc.d/init.d/httpd stop
    /etc/rc.d/init.d/httpd start
    sleep 2
    echo "Ok, we should be in business!"
    Script End>>>>>>>>
    Console Output Start>>>>>>>>
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages

    Restart Apache

    Exception in thread "main" java.lang.OutOfMemoryError: unable to create
    new
    native thread
    at java.lang.Thread.start(Native Method)
    at
    org.apache.tomcat.util.ThreadPool$ControlRunnable.<init>(ThreadPool.java:465
    )
    at
    org.apache.tomcat.util.ThreadPool.openThreads(ThreadPool.java:360)
    at org.apache.tomcat.util.ThreadPool.start(ThreadPool.java:148)
    at
    org.apache.tomcat.service.PoolTcpEndpoint.startEndpoint(PoolTcpEndpoint.java
    :245)
    at
    org.apache.tomcat.service.PoolTcpConnector.start(PoolTcpConnector.java:188)
    at
    org.apache.tomcat.core.ContextManager.start(ContextManager.java:527)
    at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:202)
    at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)

    Exception in thread "main" java.lang.OutOfMemoryError: unable to create
    new
    native thread
    at java.lang.Thread.start(Native Method)
    at
    org.apache.tomcat.util.ThreadPool$MonitorRunnable.<init>(ThreadPool.java:382
    )
    at org.apache.tomcat.util.ThreadPool.start(ThreadPool.java:149)
    at
    org.apache.tomcat.service.PoolTcpEndpoint.startEndpoint(PoolTcpEndpoint.java
    :245)
    at
    org.apache.tomcat.service.PoolTcpConnector.start(PoolTcpConnector.java:188)
    at
    org.apache.tomcat.core.ContextManager.start(ContextManager.java:527)
    at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:202)
    at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)

    Shutting down Web Service: httpd

    /etc/rc.d/init.d/httpd: fork: Resource temporarily unavailable
    Web Service: /usr/sbin/httpd
    Console Output End>>>>>>>>
  • Craig McClanahan at Aug 27, 2001 at 5:52 pm

    On Mon, 27 Aug 2001, Barnabas Yohannes wrote:

    Date: Mon, 27 Aug 2001 10:53:20 -0500
    From: Barnabas Yohannes <yohannesb@hotmail.com>
    Reply-To: tomcat-user@jakarta.apache.org
    To: tomcat-user@jakarta.apache.org
    Subject: Re: OutOfMemory - Set Java Heap Size?

    Where is this command line to set the maximum heap size located? Please
    help, I am kind of new to this staff!
    Command line options for the "java" command are documented in the JDK's
    documentation bundle (imagine that :-). An online pointer to the version
    for Solaris (the others are also available, and very similar) is:

    http://java.sun.com/j2se/1.3/docs/tooldocs/solaris/java.html

    Craig McClanahan
  • Shaun Kalley at Aug 25, 2001 at 4:21 pm
    When you set the TOMCAT_HOME and JAVA_HOME variables, also set a third
    variable called TOMCAT_OPTS with the value -Xms256m to up your initial heap
    size. This sets your initial memory allocation for the JVM that Tomcat
    runs from. I'm running a system with almost identical specs to yours and
    have "TOMCAT_OPTS=-server -Xms64m -Xmx192m". This swaps the JVM for the
    server version of HotSpot (which is said to be more appropriate for
    persistent applications which don't require an optimized startup), sets the
    base memory allocation to 64Mb, and the maximum memory allocation to
    192Mb. Oracle uses a huge amount of memory, so you probably don't want to
    set your initial heap size too high.

    Also check out http://java.sun.com/docs/hotspot/VMOptions.html to see the
    full set of options you have available for tweaking your virtual machines.

    Shaun
    At 01:00 PM 8/25/2001 +1000, you wrote:
    I run Linux/Apache/Tomcat plus Oracle on a server with 512Mb of memory. I
    have successfully implemented a couple of Internet applications using JSP,
    Servlets (plus Oracle) etc.

    For each application (and client) I start a new Tomcat session, using a
    custom server.xml for each one. All was ok, until I tried increasing Tomcat
    sessions from 6 to 7, then I received the java.lang.OutOfMemoryError when
    starting the Tomcat sessions.

    I've read through many of the posts on this subject, some of which suggest
    to increase the "heap" size. Unfortunately, I'm a newbie to Java (and Linux
    and JSP and Oracle <g>) so I don't know how to either check this heap size,
    nor how to permanently set it to a value via a script using a switch
    like -Xms256m.

    The script I use to start Tomcat follows, plus the console output. Could
    anyone advise how to set the heap please?


    Many thanks,

    Max Hugen maxhugen@hugen.com.au
    Hugen Enterprises Pty Ltd, Sydney, Australia
    www.hugen.com.au
    Internet Application Developers
    Script Start>>>>>>>>
    echo "~~~~~~~~Tomcat Startup ~~~~~~~~~~~~~"
    echo "Start an instance of Tomcat for hugen"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_he.xml
    echo "Start an instance of Tomcat for yass3i"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_yass3i.xml
    echo "Start an instance of Tomcat for isp"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_isp.xml
    echo "Start an instance of Tomcat for im2000i"
    /usr/local/tomcat/bin/startup.sh -f
    /usr/local/tomcat/conf/server_im2000i.xml
    echo "Start an instance of Tomcat for secure"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_secure.xml
    echo "Start an instance of Tomcat for aedo"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_aedo.xml
    echo "Start an instance of Tomcat for ncap"
    /usr/local/tomcat/bin/startup.sh -f /usr/local/tomcat/conf/server_ncap.xml
    # Give Tomcat time to start before restarting Apache.
    echo "Waiting 45 secs..."
    sleep 45
    # Restart Apache to register Tomcat properly.
    echo "Restart Apache"
    /etc/rc.d/init.d/httpd stop
    /etc/rc.d/init.d/httpd start
    sleep 2
    echo "Ok, we should be in business!"
    Script End>>>>>>>>
    Console Output Start>>>>>>>>
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages
    Starting tomcat. Check logs/tomcat.log for error messages

    Restart Apache

    Exception in thread "main" java.lang.OutOfMemoryError: unable to create new
    native thread
    at java.lang.Thread.start(Native Method)
    at
    org.apache.tomcat.util.ThreadPool$ControlRunnable.<init>(ThreadPool.java:465
    )
    at
    org.apache.tomcat.util.ThreadPool.openThreads(ThreadPool.java:360)
    at org.apache.tomcat.util.ThreadPool.start(ThreadPool.java:148)
    at
    org.apache.tomcat.service.PoolTcpEndpoint.startEndpoint(PoolTcpEndpoint.java
    :245)
    at
    org.apache.tomcat.service.PoolTcpConnector.start(PoolTcpConnector.java:188)
    at
    org.apache.tomcat.core.ContextManager.start(ContextManager.java:527)
    at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:202)
    at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)

    Exception in thread "main" java.lang.OutOfMemoryError: unable to create new
    native thread
    at java.lang.Thread.start(Native Method)
    at
    org.apache.tomcat.util.ThreadPool$MonitorRunnable.<init>(ThreadPool.java:382
    )
    at org.apache.tomcat.util.ThreadPool.start(ThreadPool.java:149)
    at
    org.apache.tomcat.service.PoolTcpEndpoint.startEndpoint(PoolTcpEndpoint.java
    :245)
    at
    org.apache.tomcat.service.PoolTcpConnector.start(PoolTcpConnector.java:188)
    at
    org.apache.tomcat.core.ContextManager.start(ContextManager.java:527)
    at org.apache.tomcat.startup.Tomcat.execute(Tomcat.java:202)
    at org.apache.tomcat.startup.Tomcat.main(Tomcat.java:235)

    Shutting down Web Service: httpd

    /etc/rc.d/init.d/httpd: fork: Resource temporarily unavailable
    Web Service: /usr/sbin/httpd
    Console Output End>>>>>>>>
  • Max Hugen at Aug 27, 2001 at 6:21 am
    Many thanks, Craig, Aravind and Shaun, for your comments. They are most
    appreciated.

    I set the TOMCAT_OPTS to "-server -Xms64m -Xmx192m" as you suggested
    Shaun... I wasn't aware of the HotSpot application, I'm now reading up in
    it. Thanks for the tip.

    Unfortunately, I still cannot launch a 7th Tomcat process, and I don't
    understand why not. I feel I'm missing something, but I just can't figure it
    out. 6 works, but adding a seventh raises the OutOfMemoryError.

    It does appear from the console output that Tomcat fails when it tries to
    start a PoolTCPConnector. I start two connectors for each application (ie,
    Tomcat process), one is an Ajp13ConnectionHandler, the second an
    Ajp12ConnectionHandler which I understand is required for Tomcat to be
    closed down.

    I've included one of my server.xml files below, just in case there is a
    glaring error in there. There's an xml for each application, they are all
    the same except for the different ports I've assigned, and the log and work
    file names etc.

    Any further suggestions would be most appreciated, I'm have a minor heart
    attack at thought of having to buy one server for every 6 small jsp
    applications I want to run!


    Thanks, Max Hugen



    <?xml version="1.0" encoding="ISO-8859-1"?>

    <Server>
    <!-- Debug low-level events in XmlMapper startup -->
    <xmlmapper:debug level="0" />

    <Logger name="tc_log"
    path="logs/isp_tomcat.log"
    verbosityLevel = "INFORMATION" />

    <Logger name="servlet_log"
    path="logs/isp_servlet.log"
    verbosityLevel = "INFORMATION" />

    <Logger name="JASPER_LOG"
    path="logs/isp_jasper.log"
    verbosityLevel = "INFORMATION" />

    <ContextManager debug="0" workDir="work_isp" showDebugInfo="true" >

    <!-- ==================== Interceptors ==================== -->

    <!-- ContextInterceptor
    className="org.apache.tomcat.context.LogEvents" -->

    <ContextInterceptor className="org.apache.tomcat.context.AutoSetup" />
    <ContextInterceptor className="org.apache.tomcat.context.WebXmlReader" />

    <!-- Uncomment out if you have JDK1.2 and want to use policy
    <ContextInterceptor
    className="org.apache.tomcat.context.PolicyInterceptor" /> -->

    <ContextInterceptor
    className="org.apache.tomcat.context.LoaderInterceptor" />
    <ContextInterceptor className="org.apache.tomcat.context.DefaultCMSetter"
    />
    <ContextInterceptor
    className="org.apache.tomcat.context.WorkDirInterceptor" />

    <!-- Request processing -->
    <RequestInterceptor
    className="org.apache.tomcat.request.SessionInterceptor" noCookies="false"
    />

    <!-- Find the container ( context and prefix/extension map ) for a
    request. -->
    <RequestInterceptor className="org.apache.tomcat.request.SimpleMapper1"
    debug="0" />

    <!-- Non-standard invoker, for backward compat. ( /servlet/* ) -->
    <RequestInterceptor
    className="org.apache.tomcat.request.InvokerInterceptor" prefix="/servlet/"
    debug="0" />

    <!-- "default" handler - static files and dirs. -->
    <RequestInterceptor
    className="org.apache.tomcat.request.StaticInterceptor" debug="0"
    suppress="false" />

    <!-- Plug a session manager. You can plug in more advanced session
    modules. -->
    <RequestInterceptor
    className="org.apache.tomcat.session.StandardSessionInterceptor" />

    <!-- Check if the request requires an authenticated role. -->
    <RequestInterceptor
    className="org.apache.tomcat.request.AccessInterceptor" debug="0" />

    <!-- Check permissions using the simple xml file. You can plug more
    advanced authentication modules. -->
    <RequestInterceptor className="org.apache.tomcat.request.SimpleRealm"
    debug="0" />

    <!-- Loaded last since JSP's that load-on-startup use request handling -->
    <ContextInterceptor
    className="org.apache.tomcat.context.LoadOnStartupInterceptor" />

    <!-- ==================== Connectors ==================== -->

    <Connector className="org.apache.tomcat.service.PoolTcpConnector">
    <Parameter name="handler"
    value="org.apache.tomcat.service.connector.Ajp13ConnectionHandler"/>
    <Parameter name="port" value="8104"/>
    </Connector>

    <Connector className="org.apache.tomcat.service.PoolTcpConnector">
    <Parameter name="handler"
    value="org.apache.tomcat.service.connector.Ajp12ConnectionHandler"/>
    <Parameter name="port" value="8204"/>
    </Connector>


    <Context path=""
    docBase="/home/sites/site4/web/det-isp"
    debug="0"
    reloadable="true"
    trusted="false" >
    </Context>

    </ContextManager>
    </Server>
  • Craig McClanahan at Aug 27, 2001 at 3:21 pm

    On Mon, 27 Aug 2001, Max Hugen wrote:
    Unfortunately, I still cannot launch a 7th Tomcat process, and I don't
    understand why not. I feel I'm missing something, but I just can't figure it
    out. 6 works, but adding a seventh raises the OutOfMemoryError.
    Well, have you checked your OS's memory and swap settings yet? Because
    each JVM uses its own completely separate heap space, it's quite easy to
    run out of either physical memory or swap space -- once that happens, it
    doesn't matter how big you set Java's heap size to be, because the OS
    won't be able to satisfy it anyway.

    A quick way to check the settings in your 7th setup is to start that one
    *alone* on the machine. If that works, then there's nothing wrong with
    your Tomcat settings. If it's really an OS/memory you'll probably have
    this problem with *whichever* JVM you try to start last.

    Craig
  • Max Hugen at Aug 29, 2001 at 3:29 am
    Thanks Craig.

    I'm trying to work out just what I should be doing. 'Fraid I'm rather a
    novice here. I've used the top command to see what memory is being used (see
    output below), but I'm not sure what to make of it. I can certainly start
    the 7th tomcat session on its own, if I don't start the others first, so
    tomcat settings are ok, I guess.

    If I understand things correctly, each instance of Tomcat starts its own
    JVM. The amount of memory each JVM then uses is governed by the starting
    memory (eg -Xms64m) and then "it consumes as little memory as possible"
    [from Sun site] until, presumably, it reaches the maximum allowable memory,
    eg -Xmx256m.

    The applications I am running are very small, and I don't imagine that they
    would need a great deal of memory at all. The cpu is idle about 80% most of
    the time. Does it therefore make sense to use smaller starting memories for
    the JVMs, such as -Xms32m? If I'm allowing up to 256m maximum, is that
    across all JVMs, or for each one? Does that mean I can then open 256 / 32 =
    8 instances???

    Sorry I'm asking so many dumb questions, but I'm having trouble finding the
    right sort of info on this subject, most of it seems geared towards big
    applications, and I think I really need to master this, before I rush out
    and buy another server to run only 6 more tiny applications!

    Thanks, Max Hugen
    The console output of the top command>>>>>>>>>>>>>>>>>>
    9:42am up 1 day, 14:17, 1 user, load average: 0.15, 0.06, 0.01
    271 processes: 270 sleeping, 1 running, 0 zombie, 0 stopped
    CPU states: 2.9% user, 16.3% system, 0.0% nice, 80.6% idle
    Mem: 517188K av, 509160K used, 8028K free, 193344K shrd, 75172K buff
    Swap: 131536K av, 0K used, 131536K free 123504K cached

    PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND
    30036 admin 15 0 1228 1228 880 R 0 17.1 0.2 0:19 top
    2385 root 1 0 28144 27M 2516 S 48 1.4 5.4 0:01 java
    2347 root 0 0 28144 27M 2516 S 48 0.3 5.4 0:03 java
    16308 httpd 0 0 6456 6456 6032 S 0 0.1 1.2 0:00 httpd
    1 root 0 0 120 120 48 S 0 0.0 0.0 0:04 init
    2 root 0 0 0 0 0 SW 0 0.0 0.0 0:00 kflushd
    3 root 0 0 0 0 0 SW 0 0.0 0.0 0:00 kupdate
    4 root 0 0 0 0 0 SW 0 0.0 0.0 0:00 kpiod
    5 root 0 0 0 0 0 SW 0 0.0 0.0 0:00 kswapd
    6 root -20 -20 0 0 0 SW< 0 0.0 0.0 0:00
    mdrecoveryd
    89 root 0 0 300 300 208 S 0 0.0 0.0 0:02 syslogd
    98 root 0 0 416 416 0 S 0 0.0 0.0 0:00 klogd
    649 root 0 0 152 152 68 S 0 0.0 0.0 0:00 crond
    661 root 0 0 108 108 36 S 0 0.0 0.0 0:00 inetd
    670 root 0 0 160 160 0 S 0 0.0 0.0 0:00 nlservd
    678 root 0 0 3232 3232 2200 S 0 0.0 0.6 0:00 httpd
    713 postgres 0 0 664 664 272 S 0 0.0 0.1 0:01
    postmaster
    end>>>>>>>>>>>>>>>>>>>>>>>>>>>>



    ----- Original Message -----
    From: Craig R. McClanahan
    To: Tomcat Users List ; Max Hugen
    Sent: Tuesday, August 28, 2001 1:20 AM
    Subject: Re: OutOfMemory - Set Java Heap Size?



    On Mon, 27 Aug 2001, Max Hugen wrote:


    Unfortunately, I still cannot launch a 7th Tomcat process, and I don't
    understand why not. I feel I'm missing something, but I just can't figure it
    out. 6 works, but adding a seventh raises the OutOfMemoryError.
    Well, have you checked your OS's memory and swap settings yet? Because
    each JVM uses its own completely separate heap space, it's quite easy to
    run out of either physical memory or swap space -- once that happens, it
    doesn't matter how big you set Java's heap size to be, because the OS
    won't be able to satisfy it anyway.

    A quick way to check the settings in your 7th setup is to start that one
    *alone* on the machine. If that works, then there's nothing wrong with
    your Tomcat settings. If it's really an OS/memory you'll probably have
    this problem with *whichever* JVM you try to start last.

    Craig
  • Peter at Aug 29, 2001 at 7:44 am
    I've installed tomcat-3.2.3 on win98 which works fine. However, when I
    place the .war files from the struts distribution into the /webapps
    directory and
    restart the server tomcat no longer works. Does anyone know why this is
    happening?


    Thanks

    Peter

Related Discussions

People

Translate

site design / logo © 2015 Grokbase