How to fix out of memory errors by increasing available 0memory + how to increase java heap memory in linux

Step 1: Increase Available Memory

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)

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.

Linux

To increase heap or perm gen space memory in Linux installations,
  1. Shutdown Confluence
  2. From <confluence-install>/bin (Stand-alone) or <Tomcat-home>/bin (EAR-WAR installation), open setenv.sh (you can create this file in the EAR/WAR version).
  3. Find the section
  • CATALINA_OPTS=”-Xms1024m -Xmx1024m -XX:+UseG1GC $CATALINA_OPTS in Confluence 5.8 or above
  • CATALINA_OPTS=”$CATALINA_OPTS -Xms1024m -Xmx1024m -XX:MaxPermSize=256m -XX:+UseG1GC” in Confluence 5.6 or 5.7
  • JAVA_OPTS=”-Xms256m -Xmx512m -XX:MaxPermSize=256m in previous versions
  1. See Diagnosis above and enter the appropriate values. Xmx is maximum, Xms is minimum, and MaxPermSize is PermGen.
  2. Start Confluence

Windows

To Configure System Properties in Windows Installations When Starting from the .bat File,
  1. Shutdown Confluence
  2. From <confluence-install>/bin (Stand-alone) or <Tomcat-home>/bin (EAR-WAR installation), open setenv.bat.
  3. Find the section
    • CATALINA_OPTS=”-Xms1024m -Xmx1024m -XX:+UseG1GC $CATALINA_OPTS in Confluence 5.8 or above
    • CATALINA_OPTS=”$CATALINA_OPTS -Xms1024m -Xmx1024m -XX:MaxPermSize=256m -XX:+UseG1GC” in Confluence 5.6 or 5.7
    • JAVA_OPTS=”-Xms256m -Xmx512m -XX:MaxPermSize=256m in previous versions
  4. See Diagnosis above and enter the appropriate values. Xmx is maximum, Xms is minimum, and MaxPermSize is PermGen.
  5. Start Confluence

 

Advertisements