java.lang.OutOfMemoryError: Unable to Create New Native Thread

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

As of BitbucketServer 5.x+, no logs are written to the BITBUCKET_INSTALL directory. The contents of catalina.out will be written to BITBUCKET_HOME/log/atlassian-bitbucket.log file.

Problem

The catalina.out logs report that Bitbucket Server is running out of memory:

1 2 3 4 27-Mar-2015 19:20:00.717 SEVERE [http-nio-57990-exec-5] org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun java.lang.OutOfMemoryError: unable to create new native thread at java.lang.Thread.start0(Native Method) at java.lang.Thread.start(Thread.java:691)

Cause

# Issue 1:

Bitbucket Server during normal operations will fork Git processes to complete many of it's functions. These Git processes use memory that is available to the system and does not use the memory allocated in the JVM. This error indicates that there was not enough memory for a Git process to start. More information about how much memory Bitbucket Server requires can be found at Scaling Bitbucket Server.

Workaround

# Issue 1:

Workaround:

This issue could be worked around by reduce the number of Git hosting operations allowed on the server by lowering the throttle.resource.scm-hosting in bitbucket.properties.

1 2 #Default - throttle.resource.scm-hosting=1.5*cpu throttle.resource.scm-hosting=4

Resolution

# Issue 1:

You will probably need to budget the memory of your server properly

More information about how much memory Bitbucket Server requires can be found at Scaling Bitbucket Server.

# Issue 2:

You could be running your Stash on a JVM that is only 32-Bits - and that will limit you to 4GB. This could generate performance issues for you and you will need to update your system to a 64-Bit JVM and start up Stash with that JVM.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.