How to monitor Confluence Heap memory
Asked by sowmya:

Hi,

We are frequently facing the outofmemory issue in our Confluence Application.Please let me know if anyone have idea about Monitoring the the Heap memory automatically.

Please share me the details if there is any monitoring tool ,any automation jobs or any other possible ways to fix this issue.

Thanks,

Sowmya


Answers:
author: Daniel Eads
body: Hi Sowmya,

There are several monitoring tools available that can help you see what's happening in your JVM.

Hosted as a service:

* [NewRelic](https://newrelic.com/)
* [AppDynamics](https://www.appdynamics.com/)

Running locally:

* [JConsole](https://www.cs.mun.ca/java-api-1.5/guide/management/jconsole.html#memory)

Without knowing how large your JVM heap currently is or what your environment looks like, it's hard to say off-hand if just increasing your heap would help out in your situation. With more details (max / min heap allocations, number of users, number of plugins), the Community might advise you to make some tweaks. I'd also look for activities around times you see your heap spiking - particular plugins for example might be using a lot of memory for a function triggered only by one user, which causes a spike that exhausts your remaining heap.

Finally I cannot recommend this talk enough by Atlassian's own [Denise Unterwurzacher to help inform how to do JVM memory tuning](https://www.youtube.com/watch?v=sSAHvuA0B40).

Cheers,  
Daniel

comments: author: Doug Swartz
body: In addition to the tools mentioned above, you could try out the [Java Melody plugin.](https://marketplace.atlassian.com/apps/20909/javamelody-monitoring-plugin/version-history)

Daniel is correct. More allocated heap may, or may not, help. If you don't have a good understanding of how Java manages memory, and the talk referenced above doesn't help you, you need to find or contract with someone with Atlassian application tuning experience.


author: Zak Laughton
body: Gonna hop on the "Java tuning recommendation" train here and also suggest:

* [Garbage Collection (GC) Tuning Guide](https://confluence.atlassian.com/enterprise/garbage-collection-gc-tuning-guide-461504616.html)
* [Performance Tuning](https://confluence.atlassian.com/doc/performance-tuning-130289.html)


author: sowmya
body: Hi All,

Thanks a lot for the replay.

Our application is running as a windows service,and its currently allocated with the default JVM heap memory i.e. 1024 MB.

We have previously attempted to increase memory allocated to Confluence We found that the additional memory was not recognized by Confluence, and determined that this was because we are still running an old 32 bit version of the application and JVM which does not allow for heap size beyond 1024MB.

We have around 230 users and 57 installed plugins in confluence ,i am not sure about finding out which plugin is consuming more memory. Please let me know what are the ways to check which plugin is consuming more memory.Also Please let me know if we have any script to get the JVM memory statistics details as we have JAMS available for scheduling purpose which is similar to New Relic and App Dynamics agent installation

Thanks,

Sowmya


author: Daniel Eads
body: I can speak from experience and say 1GB of heap is not sufficient for that many plugins. A near-similarly sized Confluence (user count, plugin count) I admin'd in the past required **4GB** for the usage it was getting.

Your next step is to see about running on a 64bit Java. Technically 32 bit Java will support 4GB of memory usage but if you're also running on a 32 bit operating system, you are also limited by the operating system's 4GB max RAM (meaning you can probably only get 2GB for Java, assuming nothing else is running on that server).

I would not recommend instrumenting your JVM at that heap usage given the limitations. Monitoring agents also consume a small portion of the available heap, and you don't have any to spare.

If you are on a 64 bit operating system, fixing this is as easy as telling Confluence to use a different Java runtime.

What operating system are you using (Windows, Ubuntu, etc) and can you determine if it is 64bit?


author: Doug Swartz
body: [@sowmya](/t5/user/viewprofilepage/user-id/2502449) Agree that 1 GB seems small for the number of users and plugins.

If I read what you're saying correctly, you are running an old version of Confluence. Before updating your Java version, verify the version of Java you're upgrading to is supported by the version of Confluence you have.


author: sowmya
body: Hi Daniel,

Thanks for the information.

Yes, our operating system is windows and it is of 64 bit. Can you please give me more details on the below one.

++fixing this is as easy as telling Confluence to use a different Java runtime.++

Thanks,

Sowmya


author: Daniel Eads
body: Excellent, this is progress!

At this point we should note that even with your existing 32bit Java, you should be able to increase to 2GB of heap allocation and buy yourself a little breathing room while the next steps are determined.

We've [got a KB article describing how to increase the heap allocation here if you need detailed assistance](https://confluence.atlassian.com/confkb/how-to-fix-out-of-memory-errors-by-increasing-available-memory-154071.html). In short, you want to modify the Xmx and Xms flags to 2048 MB from their current values of 1024 MB. The document describes how to find these values in a couple different ways (search for **Windows Service** on the page). The service will need to be restarted for the new heap value to take effect.

As Doug mentioned, it might be useful in knowing which version of Confluence. Java 8 is supported from Confluence 5.7 onward - what version of Confluence are you currently on?


Tags: confluence-server

server