How to debug Out of Memory Heap Space

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

Bitbucket Server recently released a change that will significantly reduce the occurrence of Out Of Memory exceptions as part of BSERV-10100 - Getting issue details... STATUS .

The following versions contain the fix: 4.14.10, 5.0.8, 5.1.6, 5.2.4, 5.3.2, 5.4.+ and any higher version.

If possible, before proceeding with the troubleshooting, we recommend upgrading to a version including the fix.


Bitbucket Server hangs or behaves unexpectedly. The atlassian-bitbucket.log will contain an error message like:

2013-11-26 16:32:46,167 ERROR [threadpool:thread-212251]  c.a.s.i.c.StateTransferringExecutor Error while processing asynchronous task
java.lang.OutOfMemoryError: Java heap space


Configure Java to produce a heapdump and a thread stack at the same time when it throws an OutOfMemoryError. Heapdumps can be used to determine what was in memory, and thereby find memory leaks and determine what parts of the system are using too much memory. To generate heapdumps/thread stacks on out of memory, add the following argument to your file in the appropriate section:

# Occasionally Atlassian Support may recommend that you set some specific JVM arguments.  You can use this variable
# below to do that.
JVM_SUPPORT_RECOMMENDED_ARGS="-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/to/heap/dump"

setenv and environment variable changes in Bitbucket Server 5.0+

Starting with Bitbucket Server 5.0, and setenv.bat have been removed. The options that were set in this file can now be set via environment variables. Where to set the environment variable depends on which Operating System you're running on.


When using the atlbitbucket service on Linux, the environment variables are ignored. You must set the parameters in (or These values will be read when the service starts.

As an example, to set JVM_SUPPORT_RECOMMENDED_ARGS, you would add this line to the file:



Set the parameter as an environment variable for the user running Bitbucket Server. For example, if you want to set JVM_SUPPORT_RECOMMENDED_ARGS, create it as an environment variable and assign the appropriate value to it. When Bitbucket Server starts using the startup scripts or service, it will pick up and apply this value.

Generating a heap dump will create a file that is the same size as your JVM, so if you have allocated 2GB to your JVM's maximum memory size, the heap dump will be 2GB. Please ensure there is adequate space on the drive for this file to be created.

Also, we do not recommend this setting for heaps larger than 2GB, unless it is specifically instructed by Atlassian Support for troubleshooting a specific problem.

DescriptionBitbucket Server hangs or behaves unexpectedly. The atlassian-bitbucket.log will contain an error message like:
ERROR [threadpool:thread-212251]  c.a.s.i.c.StateTransferringExecutor Error while processing asynchronous task
java.lang.OutOfMemoryError: Java heap space
Last modified on Jan 2, 2019

Was this helpful?

Provide feedback about this article

In this section

Powered by Confluence and Scroll Viewport.