tags:

views:

510

answers:

4

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.

+1  A: 

You could assign the Java virtual machine more memory using the -Xmx command argument. Eg. java -Xmx512M MyClass

Gordon
How do I do that with the activemq?
Marcos Roriz
+1  A: 

Check here

Specify the -Xmx argument the VM that is running the ActiveMQ - Tomcat, for example.

Bozho
I'm running in the cli, i.e., bin/activemq,I'm not running activemq on a container
Marcos Roriz
well, check the docs (provided a link in my answer)
Bozho
I checked there on the link but I didn't understand.
Marcos Roriz
+3  A: 

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 (320 KiB by default on 32-bit Java on Linux)
  • 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
habe
A: 

This doesn't look like you are running out of heap space, so don't increase that (the -Xmx option). Instead, your application is running out of process memory and decreasing the heap space will free up process memory for native use. The question is, why you are using so much process memory? If you don't use JNI, you probably have created too many threads, and habe's post has explained how to do fix that.

FelixM