How to generate a heap dump

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

Summary

Sometimes you may see that Bitbucket Server is holding onto a chunk of memory over a period of time. In such a situation, it is useful to find out what is stacking up in the memory by analysing the heap dump.

Raising Xmx is only a temporary band-aid. As stated in Scaling Bitbucket Data Center, running Bitbucket Server with the default Xmx of 1024 MB should be fine for most of our customers.

Solution

Automatically Generating a Heap Dump when Bitbucket Server Hits OutOfMemory Error

Typically, we would like to analyse the heap dump produced when Bitbucket Server crashed from an OutOfMemory Error. For this, you can add additional JVM parameters like below:

1 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=<path to this heap dump file>

If you do not set the HeapDumpPath parameter, by default the heap dump will be saved in the folder where Tomcat is run from.

Please refer to How to debug Out of Memory Heap Space for more details on this.

Manually Generating a Heap Dump when Bitbucket Server Stops Responding

It is also possible to get a heap dump manually using a JDK bundled tool called jmap, although we recommend that you use the automatic method above for best results.

For Linux/Solaris-based Operating Systems:

Execute the following command on Linux OS:

1 2 PID=`ps aux | grep -v search | grep -v mesh | grep -i bitbucket | grep -i java | awk -F '[ ]*' '{print $2}'` $JAVA_HOME/bin/jmap -dump:format=b,file=heap.bin $PID

For Windows:

Find your Bitbucket Server process ID (see below) and then execute the command below on a Windows command line:

1 %JAVA_HOME%\bin\jmap -dump:format=b,file=heap.bin <pid>

To find out the process ID for your Java process in Windows, you can use Process Explorer from Microsoft.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.