Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an Ubuntu server 12.04 using a reverse proxy so that tomcat runs on top of apache. And I have a confluence instance on that machine, and a ticket system. So nothing special.

Memory is 8GB that's more than enough for this use.

From time to time, and in the last few days more often my confluence page crashes.

The log (confluence\logs\catalina.2014-05-06) shows this :

SEVERE: Socket accept failed
java.lang.OutOfMemoryError: Java heap space

So how can I avoid this? How can I give that process more memory.

share|improve this question
If I get your setup correctly, your confluence installation is running on tomcat. The option to change memory available to java as documented in man java is "-Xmxn", where "n" should be replaced by a number. In order to put a limit of 100 MB for Javas memory allocator, you'd set it to "-Xmx100m". This has to be set in the options for tomcat - see: – soulsource May 6 '14 at 11:00
That is the tomcat logs? – MickyInTheSky May 6 '14 at 11:08
yes its running on tomcat, but using the reverse proxy. this is a common setup documented in the confluence installation guide. How do i see the actual memmory available for java? thx – Private May 6 '14 at 11:27
Can you tell me where i can set the parameters? I coudlnt find the right spot in , am I wrong there? – Private May 6 '14 at 12:35
up vote 4 down vote accepted

In my system I have edited the file


with these rows

HEAP="-Xms2048m -Xmx2048m" 
export JAVA_OPTS="$HEAP"

After restart tomcat you can see in the status section the memory allocated

share|improve this answer
On 14.04, with tomcat7 installed from the repositories, you should edit /etc/default/tomcat7. – Matt South Oct 1 '15 at 13:58
For Ubuntu 15.04 and tomcat8 installed from the repositories, edit /etc/default/tomcat8. – Derek Mahar Nov 18 '15 at 21:12

The reason for the error is due to the way Java allocates memory. Your applications are allowed to use only limited amount of memory. This limit is specified during the application startup.

Allowed maximal size is set during the JVM launch by specifying JVM parameters such as -Xmx. If you do not explicitly set the sizes, platform-specific defaults will be used.

So – the “java.lang.OutOfMemoryError: Java heap space” error will be triggered when you try to add more data into the heap space area in memory, but the size of this data is larger than the JVM can accommodate in the Java heap space.

So the obvious way is to increase (or add if missing) the maximal possible heap size specified via -Xmx parameter. But in many cases you are just hiding symptoms instead of solving the underlying problem. To see the full explanation of the java.lang.OutOfMemoryError: Java heap space error, check out the Plumbr performance tuning site.

share|improve this answer

You can also do it in tomcat/bin/ file and restart tomcat:

export JAVA_OPTS="-Xms512m -Xmx1024m"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.