Confluence java.lang.OutOfMemoryError: Java heap space, what is the correct setting?
Asked by Axel Endler:

**Environment**   
Atlassian Confluence 6.12.0   
mysql Ver 15.1 Distrib 5.5.60-MariaDB  
openjdk version "1.8.0_181"  
**Parameter** /data/atlassian/confluence/jre//bin/java -Djava.util.logging.config.file=/data/atlassian/confluence/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -XX:ReservedCodeCacheSize=256m -XX:+UseCodeCacheFlushing -Dconfluence.context.path=/confluence -Datlassian.plugins.startup.options= -Dorg.apache.tomcat.websocket.DEFAULT_BUFFER_SIZE=32768 -Dsynchrony.enable.xhr.fallback=true -Xms1024m -Xmx1024m -XX:+UseG1GC -Datlassian.plugins.enable.wait=300 -Djava.awt.headless=true -XX:G1ReservePercent=20 -Xloggc:/data/atlassian/confluence/logs/gc-2020-07-10_08-40-18.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=2M -XX:-PrintGCDetails -XX:+PrintGCDateStamps -XX:-PrintTenuringDistribution -Dignore.endorsed.dirs= -classpath /data/atlassian/confluence/bin/bootstrap.jar:/data/atlassian/confluence/bin/tomcat-juli.jar -Dcatalina.base=/data/atlassian/confluence -Dcatalina.home=/data/atlassian/confluence -Djava.io.tmpdir=/data/atlassian/confluence/temp org.apache.catalina.startup.Bootstrap start  
**Result after 7 hours** catalina.2020-07-01.log:01-Jul-2020 02:27:15.823 SEVERE \[http-nio-8090-exec-1\] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet \[dispatcher\] in context with path \[/synchrony-proxy\] threw exception \[Handler processing failed; nested exception is java.lang.OutOfMemoryError: Java heap space\] with root cause  
java.lang.OutOfMemoryError: Java heap space  
at java.util.LinkedHashMap.newNode(LinkedHashMap.java:256)  
at java.util.HashMap.putVal(HashMap.java:631)  
at java.util.HashMap.put(HashMap.java:612)


Answers:
author: Sachin
body: If you are seeing some performance issues or slowness. The first thing I would do is check the current [maximum heap allocation](https://confluence.atlassian.com/confkb/how-to-fix-out-of-memory-errors-by-increasing-available-memory-154071.html) on your instance lets say its 1GB, it is possible that you are simply running out of memory to perform the tasks that need to be performed on it. If you think that this is the case, a possible resolution step would be to increase the heap allocation on the JVM, so increase the -XX:MaxPermSize parameter in 256mb increments until the error stops occurring.  

Here are some helpful Resources:  

[Server Hardware Requirements Guide](https://confluence.atlassian.com/doc/server-hardware-requirements-guide-30736403.html)  
[Memory Usage and Requirements](https://confluence.atlassian.com/doc/memory-usage-and-requirements-130882.html)  
[Managing Application Server Memory Settings](https://confluence.atlassian.com/doc/managing-application-server-memory-settings-32899336.html)  
[How to analyze thread dumps](https://confluence.atlassian.com/confkb/how-to-analyze-thread-dumps-788039144.html)  

comments: author: Axel Endler
body: Will try tonight (/data/atlassian/confluence/bin/setenv.sh):  
old: CATALINA_OPTS="-Xms1024m -Xmx1024m -XX:+UseG1GC ${CATALINA_OPTS}"  
new: CATALINA_OPTS="-Xms1024m -Xmx1**280**m -XX:+UseG1GC ${CATALINA_OPTS}"


author: Sachin
body: Nice! Let us know how it goes.


author: Sachin
body: You can ignore those Warnings for now [@Axel Endler](/t5/user/viewprofilepage/user-id/714721), glad to hear that it's performing better now.


Tags: server