Confluence crashes due to 'OutOfMemoryError Java heap space' error
Platform Notice: Data Center Only - This article only applies to Atlassian apps 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
If Confluence is currently crashing: First enable heap dump on OOM so the next crash captures diagnostic data. Add these JVM args: -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=<path>. Without a heap dump, root cause analysis is much harder.
Problem
Confluence hangs or behaves unexpectedly.
The atlassian-confluence.log will contain an error message like:
java.lang.OutOfMemoryError: Java heap spaceDiagnosis
Configure Java to produce a heap dump when it throws an OutOfMemoryError. Heap dumps can be used to determine what was in memory, identify memory leaks, and determine which system components are over-consuming memory. To generate a heap dump upon encountering an OutOfMemoryError, add the following arguments to your Confluence application, as detailed in the Configuring System Properties document: '-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=<heap_dump_file_path>'.
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=<heap_dump_file_path>
Generating a heap dump will create a file that is the same size as your JVM heap, so if you have allocated 2 GB to your JVM's maximum heap size, the heap dump will be 2 GB.
Please ensure there is enough space on the drive or directory defined on the <heap_dump_file_path> 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.
Cause
The Java heap space allocation has been exceeded. This can happen either from a memory leak in the application or from normal usage requiring more memory.
There are several known causes:
The XML Backup is one known memory hog. Check Cannot create or restore XML backup due to OutOfMemory errors in Confluence Data Center.
Heavy usage of the Office Connector or large office files can cause Out Of Memory Errors, for example, CONF-17113.
Using HSQLDB (the evaluation database) can cause memory problems.
Upgrading Confluence from a version pre-3.5 to a version 3.5 or above, if Confluence was already close to using the maximum heap space, as Confluence's memory use increased by about 250 MB with version 3.5.
Common root causes
Symptom | Likely cause | Next step |
|---|---|---|
OOM during page export/PDF generation | Large page or attachment | Increase Xmx temporarily; identify the offending page |
OOM during search or reindex | Index buffer too small | Increase Xmx; rebuild index if needed |
OOM under normal load | Memory leak (often Marketplace app) | Capture heap dump, analyze with MAT/VisualVM |
OOM after upgrade | Increased memory requirements in new version | Check release notes; increase Xmx |
Resolution
If you're using the XML backup, disable it and use the Production Backup Strategy. Check Cannot create or restore XML backup due to OutOfMemory errors in Confluence Data Center for more information.
Upgrade Confluence - we continue to fix root causes for Out Of Memory Errors.
If you're using the evaluation database, Migrate to a Production Database.
If your usage patterns have increased, you likely just need to tweak your memory settings. See Fix Out of Memory errors by Increasing Available Memory. When increasing heap space, pay attention to Garbage Collection performance.
Verification
After increasing heap or fixing the root cause:
Monitor JVM heap usage via JConsole or VisualVM during normal load
Confirm no OOM errors appear in
atlassian-confluence.logover 24-48 hoursVerify GC pauses are within acceptable thresholds
If using a Marketplace app, monitor its memory footprint specifically
When this won't help
This article does not cover:
OutOfMemoryError types other than "Java heap space" (e.g. PermGen, Metaspace)
Server hardware OOM (kernel killing Java process) — see system memory KB
Confluence Cloud — Atlassian-managed JVM, no customer tuning available
Related articles
Was this helpful?