Bitbucket crashes or stops responding due to java.lang.OutOfMemoryError: Java heap space

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

Note that this knowledge base article was created for the Data Center version of the product. Data Center knowledge base articles 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

Problem

Bitbucket crashes or stops responding. The following appears in the atlassian-bitbucket.log:


java.lang.OutOfMemoryError: Java heap space

Resolution

Scenario #1

If you are using third-party apps that use more resources, allocate more heap space. We don't recommend setting the heap larger than 2GB, unless it is specifically instructed by Atlassian Support for troubleshooting a specific problem.
Please read Scaling Bitbucket Data Center - Memory to know more about allocating memory. If you are certain from your investigation that a third-party app is the cause, you may set the heap size for Bitbucket on your own.

Scenario #2

Spikes in performance load can cause your instance to encounter this error. Reach out to Atlassian Support to troubleshoot this further.

Cause

What does this generally mean?

The most common reason for the java.lang.OutOfMemoryError: Java heap space error is simple – you try to fit an XXL application into an S-sized Java heap space. That is – the application just requires more Java heap space than is available to it to operate normally.

Other causes for this OutOfMemoryError message are more complex and are caused by a programming error:

  • Spikes in usage/data volume. The application was designed to handle a certain amount of users or a certain amount of data. When the number of users or the volume of data suddenly spikes and crosses that expected threshold, the operation that functioned normally before the spike ceases to operate and triggers the java.lang.OutOfMemoryError: Java heap space error.
  • Memory leaks. A particular type of programming error will cause your application to constantly consume more memory. Every time the application's leaking functionality is used, it leaves some objects behind in the Java heap space. Over time, the leaked objects consume all of the available Java heap space and trigger the already familiar Java.lang.OutOfMemoryError: Java heap space error.

Common reasons observed in Bitbucket Data Center

  1. Third-party apps which requires more resources
    • Third-party apps like Awesome Graph may require allocating more memory, if you have many third-party apps and facing OutOfMemory issues, you need to increase the heap size.

Diagnosis

Check the  atlassian-bitbucket.log for specific log entries mentioned above and for a detailed analysis have a look at  How to debug Out of Memory Heap Space.


Last modified on Feb 12, 2025

Was this helpful?

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