Reputation: 4106
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.
Upvotes: 6
Views: 12857
Reputation: 724
Your case corresponds to massive number of threads. There are 3 ways to solve it:
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
Upvotes: 11
Reputation: 21
We were running into this issue on a Linux (RedHat Enterprise 5) system and discovered that on this build the nprocs ulimit in /etc/security/limits.conf
actually controls the number of threads a user can spawn.
You can view this limit using the ulimit -a
command.
Out of the box this was set to a soft limit of 100 and a hard limit of 150, which is woefully short of the number of threads necessary to run a modern App Server.
We removed this limit altogether and it solved this issue for us.
Upvotes: 2
Reputation: 4843
You could assign the Java virtual machine more memory using the -Xmx command argument.
Eg. java -Xmx512M MyClass
Upvotes: 1
Reputation: 597076
Specify the -Xmx
argument to the VM that is running the ActiveMQ - Tomcat, for example.
Upvotes: 1
Reputation: 1506
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.
Upvotes: 0