Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveMQ OutOfMemory Can't create more threads

Tags:

java

activemq

I'm simulating a overload of a server and I'm getting this error:

java.lang.OutOfMemoryError: unable to create new native thread

I've read in this page http://activemq.apache.org/javalangoutofmemory.html, that I can increase the memory size. But how do I do that? Which file I need to modify,? I tried to pass the arguments by the bin/activemq script but no luck.

like image 939
Marcos Roriz Junior Avatar asked Nov 27 '09 13:11

Marcos Roriz Junior


1 Answers

Your case corresponds to massive number of threads. There are 3 ways to solve it:

  • reduce number of threads (i.e., -Dorg.apache.activemq.UseDedicatedTaskRunner=false in the document)
  • reduce per-thread stack size by -Xss option (default values: 320 KiB for 32-bit Java on Win/Linux, 1024 KiB for 64-bit Java on Win/Linux, see doc)
  • reduce (not extend) heap size -Xmx option to make a room for per-thread stacks (512 MiB by default in ActiveMQ script)

Note: If stack or heap is too small, it must cause another OutOfMemoryError.

You can specify them using ACTIVEMQ_OPTS shell variable (in UNIX). For example, run ActiveMQ as

ACTIVEMQ_OPTS=-Xss160k bin/activemq
like image 147
habe Avatar answered Sep 27 '22 21:09

habe