This page last changed on Jul 22, 2008 by rhartono.

I am getting Out of Memory errors, how can I allocate more memory to tomcat?

Look for the term PermGen Space, which is distinct from heap space, after your java.lang.outOfMemory exception. Both are discussed in this page.

Since the default memory setting usually is around 64 or 128MB (256MB in Confluence 2.2 and later), you might have to adjust the settings to run a bigger Confluence instance with sufficient memory.

On this page:

Error formatting macro: toc: java.lang.NullPointerException

Increasing Memory when Running as a Windows Service

If you are running Confluence as a Windows service, you can increase the memory using two ways, via the Windows Registry edit or by running the Command line Tomcat's tomcat5.exe. For example:

tomcat5 //US//Confluence --JvmMs 1024 --JvmMx 1024

If you would like to set its memory beyond 1024MB, setting the memory via the Windows registry will not work and may even cause the service to refuse to start. We recommend that you update the memory using Tomcat's tomcat5.exe like the above example.

The US parameter stands for Update Service. You can refer to Apache's Windows Service How To for more information.

Confluence 2.6 with Tomcat 5.5

If you are running Tomcat standalone, you can change the following settings.

Do not set your memory using CATALINA_OPTS, because this is overridden by JAVA_OPTS.

On Linux

  • In the unpacked Confluence standalone directory, edit the file bin/setenv.sh
  • Edit the line beginning with JAVA_OPTS= substituting new values for -Xms (starting memory) and -Xmx (maximum memory)
  • Leave the rest of the options in that line unchanged

An example of a minimal setting for a large system - max heap size is set to 1Gb :

JAVA_OPTS="-Xmx1024m $JAVA_OPTS -Djava.awt.headless=true "

On Windows

  • In the unpacked Confluence standalone directory, edit the file bin/setenv.bat
  • Edit the line beginning with set JAVA_OPTS= substituting new values for -Xms (starting memory) and -Xmx (maximum memory)
  • Leave the rest of the options in that line unchanged

Other OutOfMemoryErrors

Other factors such as system load and allocating too much memory to your JVM Heap can also cause OutOfMemory Errors. For more information, you can refer to the JIRA documentation on Causes of OutOfMemoryErrors.

OutOfMemoryError: unable to create new native thread

This error occurs when the operating system is unable to create new threads. This is due to the JVM Heap taking up the available RAM.

Big heaps take away from the space that can be allocated for the stack of a new thread

For Linux the maximum heap size of the JVM cannot be greater than 2GB. If you only have 2GB RAM in your server, it is not recommended to set the Max size of the JVM that high.
The size of the stack per thread can also contribute to this problem. The stack size can reduce the number of threads that can be created.

To fix this problem, you should reduce the size of your JVM Heap and also the size of the stack per thread.
The stack size can be changed with the following (example) parameter:

"-Xss512k"

Please refer to this guide as a reference for JVM tuning.

OutOfMemoryError: GC overhead limit exceeded

This error indicates that the JVM took too long to free up memory during its GC process. This error can be thrown from the Parallel or Concurrent collectors.

The parallel collector will throw an OutOfMemoryError if too much time is being spent in garbage collection: if more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered, an OutOfMemoryError will be thrown. This feature is designed to prevent applications from running for an extended period of time while making little or no progress because the heap is too small. If necessary, this feature can be disabled by adding the option -XX:-UseGCOverheadLimit to the command line.

This kind of OutOfMemoryError can be caused if your java process is starting to use swapped memory for its heap. This will cause the JVM to take a lot longer than normal to perform normal GC operations. This can eventually cause a timeout to occur and cause this error.

To overcome this issue, you need to make sure that all processes can't allocate more memory than there is system memory. In practice this is impossible to do for all processes. At a minimum you should make sure that all your jvm's do not have a total maximum memory allocation than your normally available system memory.

Please refer to this guide for more information.

OutOfMemoryError: Requested array size exceeds VM limit

This error indicates that Confluence attempted to allocate an array that is larger than the Java heap size. More details regarding this error can be found here.
This is due to a known limitation of the JVM as documented here. We have a bug lodged against this, to better handle this exception in Confluence.

On OS X

If you are using the 'serveradmin start appserver' to start and stop tomcat, then you will need to update /usr/share/servermgrd/bundles/servermgr_appserver.bundle/Contents/Resources/run.sh

Permanent Generation Size (PermGen)

If you get the error message: java.lang.OutOfMemoryError: PermGen space this means that you have exceeded Java's fixed 64Mb block for loading class files. You will need to add the argument -XX:MaxPermSize=256m to JAVA_OPTS, in addition to any argument you use to set the heap size.

JAVA_OPTS="-Xms128m -Xmx1024m -XX:MaxPermSize=256m $JAVA_OPTS -Djava.awt.headless=true "

If you are running Confluence as a Windows service, you can refer to the JIRA documentation on Increasing JIRA memory, which also describes how to increase the PermGen memory in Windows Service. Confluence is done similarly.

Please refer to this link for more information.

JDK 1.4 does not provide information why the OutOfMemory error occurred.
JDK 1.5 or 1.6 are recommended as they provide a description of the error as in the above example.

Confluence 2.8 Installer Memory Settings

You need to modify the settings inside the following files found in the <Install-Directory>\Application\conf directory.

Windows users
Mac users
Settings
  • Initial memory
    wrapper.java.initmemory is the Xms (minimum amount of memory assigned to JVM)
  • Max memory
    wrapper.java.maxmemory is the XmX (maximum memory assigned to JVM)
RELATED TOPICS

Managing Application Server Memory Settings
Application Server Configuration
FAQ Home
Tomcat JVM options and Modify the Default JVM Settings
Logging A Thread Dump

Document generated by Confluence on Aug 07, 2008 19:08