How to fix out of memory errors by increasing available memory
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
Purpose
Java applications like JIRA, Crowd and Confluence run in a "Java virtual machine" (JVM), instead of directly within an operating system. When started, the Java virtual machine is allocated a certain amount of memory, which it makes available to applications like Confluence. By default, Java virtual machines are allocated 64Mb of memory, no matter how many gigabytes of memory your server may actually have available. 64Mb is inadequate for most Confluence installations, and so this needs to be increased.
Diagnosis
Solution
Step 1: Increase Available Memory
We aren't really able to give a concrete recommendation for the amount of memory to allocate, because that will depend greatly on your server setup, the size of your user base, and their behavior. You will need to find a value that works for you, i.e. no noticeable GC pauses, and no OutOfMemory errors.
For reference, the 3 most common parameters used to change the memory (heap) allocation are:
- Xms - the minimum size of the heap
- Xmx - the maximum size of the heap
-XX:MaxPermSize - the maximum size of PermGen (this is not used in Java 8 and above)
In case you need advice regarding how much memory you should use please check this page for some examples of hardware specifications.
If you do decide to increase the memory settings, there are a few general guidelines to follow:
- Increase Xmx in small increments (eg 512mb at a time), until you no longer experience the OutOfMemory error. This is because increasing the heap beyond the capabilities of your server to adequately Garbage Collect can cause other problems (eg performance/freezing)
If your error is java . lang . OutOfMemoryError : PermGen space, increase the -XX:MaxPermSize parameter in 256mb increments until the error stops occurring.
- If your error does not reference PermGen, there is no need to increase it. In a simplistic explanation, PermGen is used to store classes, and is generally quite static in size, and has been removed in Java 8. More info here.
- Consider setting Xms and Xmx to the same value, as this can decrease the time GC takes to occur, as it will not attempt to resize the heap down on each collection.
See our Garbage Collection (GC) Tuning Guide for more detailed information.
- It is possible to set the Xms and Xms values in either a gigabyte or megabyte format.
When setting these values in megabytes, set the value by multiplying the desired memory level by 1024. For example, to set the memory at 2 gigabytes, configure the Xms and Xmx to 2048m (2GB x 1024MB):
-Xms2048m -Xmx2048m
For the same example using gigabytes, simply use the following:
-Xms2g -Xmx2g
When setting the value in gigabytes, do not use .5 increments as this will cause the JVM to not start properly.
Linux
Windows (starting from .bat file)
Windows Service
Step 2: Verify Your Settings
To verify what settings are in place, check Viewing System Information. You should see a section called "Java Runtime Arguments".
Look for Xmx (maximum) and Xms (minimum) settings.
Alternatively, on Linux, run
ps -aux | grep java
to see the environment parameters.