TrailDragon
TrailDragon

Reputation: 456

Xpages/Domino Java Memory usage clarification

We have an intermittent performance issue on one of our servers reported by a couple of users when using one particular XPages application. My first thought was that it was related to Java Memory usage and poor code recycling so I'm starting there. At the moment, according to Mark Leusink's fantastic Debug Toolbar, the usage data for the server (64-bit Windows machine with 32Gb physical RAM) looks like this:

enter image description here

I'd like to confirm my understanding of the figures:

  1. Maximum Heap Size - I'm okay with this and know how to change it (and that recommended setting is a quarter of the available RAM but due to low user population on this server, I'm sure 2Gb is more than adequate)
  2. Total Allocated - this seems low to me but am I correct in that this is automatically set by the server and that, if more Java memory is needed then it will allocate more (up to the amount specified in the maximum heap size?) Does this happen only if garbage collection cannot free enough space to load a new java object?
  3. Used - I believe this shows the memory being used across the server and not just in the application containing the debug toolbar itself. Will this only show the memory being used by the Domino HTTP task (so all XPages apps) or can it be affected by Java agents too?

Bonus questions:

Thanks

Upvotes: 0

Views: 1330

Answers (1)

Mark Leusink
Mark Leusink

Reputation: 3757

The information shown in the toolbar are the standard numbers that the JVM provides: totalMemory(), maxMemory() and freeMemory(). See this question for a detailed explanation. The three values given are for the entire JVM, not a specific application.

In the Domino HTTP JVM you can set the maxMemory with the HTTPJVMMaxHeapSize notes.ini parameter. You cannot set/ change the total allocated (totalMemory) value, but that's also not needed. The JVM will simply allocate more memory when it needs it (up to the value of maxMemory). When garbage collection has been performed, it will eventually also free this memory again.

Java agents do not affect these numbers. The only exception would be a Java agent that runs in the HTTP process (e.g. called from a browser using the ?OpenAgent command).

On a server you can run into memory issues (OutOfMemory exceptions) if the JVM needs more memory that can be allocated. You can monitor this value by creating a simple XAgent to output the current values for the JVM:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core" rendered="false" viewState="nostate">
  <xp:this.afterRenderResponse><![CDATA[#{javascript:

var externalContext = facesContext.getExternalContext();
var writer = facesContext.getResponseWriter();
var response = externalContext.getResponse();

response.setContentType("application/json"); 

response.setHeader("Cache-Control", "no-cache");

var max = java.lang.Runtime.getRuntime().maxMemory();
var free = java.lang.Runtime.getRuntime().freeMemory();
var total = java.lang.Runtime.getRuntime().totalMemory();

var memory = {
    max : max,
    total : total,
    free : free,
    available : (max - total) + free
};

writer.write( toJson(memory) ); 

writer.endDocument();
}]]>
  </xp:this.afterRenderResponse>
</xp:view>

Upvotes: 3

Related Questions