You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Max Hugen <ma...@hugen.com.au> on 2001/08/25 05:00:41 UTC

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


Re: OutOfMemory - Set Java Heap Size?

Posted by Shaun Kalley <sh...@e-ztext.com>.
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>>>>>>>>


Re: OutOfMemory - Set Java Heap Size?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 27 Aug 2001, Barnabas Yohannes wrote:

> Date: Mon, 27 Aug 2001 10:53:20 -0500
> From: Barnabas Yohannes <yo...@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


Re: OutOfMemory - Set Java Heap Size?

Posted by Barnabas Yohannes <yo...@hotmail.com>.
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" <cr...@apache.org>
To: "Tomcat Users List" <to...@jakarta.apache.org>; "Max Hugen"
<ma...@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 <ma...@hugen.com.au>
> > Reply-To: tomcat-user@jakarta.apache.org, Max Hugen
<ma...@hugen.com.au>
> > To: Tomcat Users List <to...@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>>>>>>>>
> >
> >
>
>

RE: OutOfMemory - Set Java Heap Size?

Posted by Aravind Naidu <ar...@eha.net>.
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 [mailto: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 <ma...@hugen.com.au>
> Reply-To: tomcat-user@jakarta.apache.org, Max Hugen
<ma...@hugen.com.au>
> To: Tomcat Users List <to...@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>>>>>>>>
>
>


Re: OutOfMemory - Set Java Heap Size?

Posted by "Craig R. McClanahan" <cr...@apache.org>.
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 <ma...@hugen.com.au>
> Reply-To: tomcat-user@jakarta.apache.org, Max Hugen <ma...@hugen.com.au>
> To: Tomcat Users List <to...@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>>>>>>>>
>
>