ActiveMQ OutOfMemory Unable to create more threads.

I simulate server overload and I get this error:

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

I read on this page http://activemq.apache.org/javalangoutofmemory.html that I can increase the size of the memory. But how do I do this? Which file do I need to change? I tried passing arguments to the bin / activemq script, but no luck.

+5
source share
5 answers

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

  • reduce the number of threads (i.e. -Dorg.apache.activemq.UseDedicatedTaskRunner = false in the document)
  • -Xss ( : 320 KiB 32- Java Win/Linux, 1024 KiB 64- Java Win/Linux, . doc)
  • ( ) -Xmx, (512 MiB ActiveMQ script)

. , OutOfMemoryError.

, ACTIVEMQ_OPTS ( UNIX). , ActiveMQ

ACTIVEMQ_OPTS=-Xss160k bin/activemq
+10

Java -Xmx.
. java -Xmx512M MyClass

+1

-Xmx , ActiveMQ - Tomcat, .

+1

Linux (RedHat Enterprise 5) , nprocs ulimit /etc/security/limits.conf , .

ulimit -a.

100 150, , .
.

+1

This is not like you are running out of empty space, so do not increase it (option -Xmx). Instead, your application runs out of process memory, and reducing heap space frees up process memory for its own use. The question is why are you using so much process memory? If you are not using JNI, you probably created too many threads, and the habe message explained how to fix this.

0
source

All Articles