Bitbucket Server is not available due to "java.lang.OutOfMemoryError: unable to create new native thread"

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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

Problem

A short time after starting Bitbucket Server, the application stops without any shutdown request.

The following appears in the catalina.out log:

(info) As of Bitbucket Server 5.x, catalina.out will no longer exist. It will be written to atlassian-bitbucket.log instead.

java.lang.OutOfMemoryError: unable to create new native thread

Diagnosis

Environment

  • Linux using systemd as the default init system
    • For example, Ubuntu 15.10+ first introduced systemd as the default

Diagnostic Steps

  • No other processes can be started on the server. For example running a ps command returns the following:
atlbitbucket@bitbucket:~$ ps -efH | grep java
-bash: fork: retry: No child processes

Cause

The UserTasksMax setting in systemd does not allow the creation of a sufficient number of threads.

This setting has a default of 512.

Resolution

  1. Increase the value of the DefaultTasksMax setting by changing the relative line in the /etc/systemd/system.conf to provide a higher number (for example 12288):

    DefaultTasksMax=12288
  2. Restart Bitbucket Server for the change to take effect

Last modified on May 2, 2017

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.