java.lang.OutOfMemoryError: unable to create new native thread - Cause and Solution

There are several types of OutOfMemoryError in Java e.g. OutOfMemoryError related to Java heap space and permgen space, and a new one coming in Java 8, Java.lang.OutOfMemoryError: MetaSpace. Each and every OutOfMemoryError has their own unique reason and corresponding unique solution. For example, java.langOutOfMemoryError: Java Heap Space comes when the application has exhausted all heap memory and tries to create an object which requires further memory allocation, that time JVM throws this error to tell the application that it's not possible to create any object. Similarly java.lang.OutOfMemoryError: PermGen Space comes when there is no more memory in permgen space and application tries to load more classes (as class metadata is stored in this area) or tries to create new String (because prior to Java 7 String pool has also existed on permgen space).
Read more »