user3593497
user3593497

Reputation: 1

Openshift - java.lang.OutOfMemoryError: unable to create new native thread"

I have hosted my app on Openshift PAAS. My app does not create thread explicity. I have been getting following error

m.sun.jersey.spi.container.ContainerResponse mapMappableContainerException SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container java.lang.OutOfMemoryError: unable to create new native thread

How do I resolve the error? I don't have the access to change ulimit as I am using hosted server.

Upvotes: 0

Views: 4391

Answers (1)

Ivo
Ivo

Reputation: 444

Generally, you face “java.lang.OutOfMemoryError: Unable to create new native thread” whenever JVM is asking a new thread from the OS. Whenever the underlying OS cannot allocate a new native thread, this OutOfMemoryError will be thrown. The exact limit for native threads is platform dependent.

But in general, the situation causing the java.lang.OutOfMemoryError: Unable to create new native thread goes through the following phases:

  1. A new Java thread is requested by application running inside the JVM
  2. JVM native code proxies the request to create a new native thread to the OS
  3. OS tries to create a new native thread which requires memory to be allocated to the thread
  4. The OS will refuse native memory allocation either because the 32-bit Java process size has depleted its memory address space e.g. (2-4) GB process size limit has been hit or the virtual memory of the OS has been fully depleted
  5. The java.lang.OutOfMemoryError: Unable to create new native thread error is thrown.

More often than not, the limits on new native threads hit by the OutOfMemoryError indicate a programming error. When your application is spawning thousands of threads then chances are that something has gone terribly wrong – there are not many applications out there which would benefit from such a vast amount of threads

Upvotes: 1

Related Questions