• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ganesh Gore
Greenhorn
Posts: 24
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic