Resolving OutOfMemoryError: Failed to create a thread
The java.lang.OutOfMemoryError: Failed to create a thread message occurs when the system does not have enough resources to create a new thread.
About this task
There are three possible causes for the java.lang.OutOfMemoryError: Failed to create a thread message:
- Inadequate user/application resources.
- The system run out of memory to use for the new thread. Threads require memory for internal JVM structures, a Java™ stack, and a native stack.
- There are too many threads already running and the system run out of internal resources to create new threads.
Use the following steps (in order) to correct this error:
Procedure
- Use the ulimit -u command to set the maximum allowed processes per user. Linux has a maximum allowed process per user limit, which translates into Java threads. If the current value is low (default is 1024), then set it to 10,000.
- Increase the amount of memory available by lowering the size of the Java heap in the -Xmx option.
- Check your space requirements by using the df -k command.
- Lower the number of used threads.