wood burning stoves 2.0*
The moose likes Threads and Synchronization and the fly likes Tomcat : Exception in thread ...... java.lang.OutOfMemoryError: unable to create new native thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Tomcat : Exception in thread ...... java.lang.OutOfMemoryError: unable to create new native thread" Watch "Tomcat : Exception in thread ...... java.lang.OutOfMemoryError: unable to create new native thread" New topic
Author

Tomcat : Exception in thread ...... java.lang.OutOfMemoryError: unable to create new native thread

Ganesh Gore
Greenhorn

Joined: Jan 03, 2011
Posts: 24

Hello,

I am using Tomcat server. On running multiple threads several times in my application I am getting error "java.lang.OutOfMemoryError: unable to create new native thread". Using method Thread.activeCount() I tried to get active thread count each time . I found out that as the thread were started, thread count gradually increased. But even though their respective run() mehtod is getting over, still the count of active thread is still same. Thus after creating several threads, the active count exceed a certain limit and the tomcat is crashing.

Thank you in advance.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12789
    
    5
Tomcat creates a pool of Threads to handle requests, you can configure the maximun number in server.xml - as I recall, the default is 150.

You should only be creating threads in your application if your really really know what you are doing.

What is the Thread count you get by calling activeCount?

Bill
Ganesh Gore
Greenhorn

Joined: Jan 03, 2011
Posts: 24

Yes the max thread limit is 150 but in case of my sever.xml file that line is commented. Is there any way that the thread count can be controlled through programming. Since destroy() and suspend() methods are deprecated any other way to destroy the thread?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat : Exception in thread ...... java.lang.OutOfMemoryError: unable to create new native thread