Skip to main content link. Accesskey S

XPages Wiki

Submit Search

YouAtNotes XPages Wiki


Home > Getting ready for production > Memory Usage and Performance

Memory Usage and Performance

ShowTable of Contents
A collection of tipps for optimizing memory usage and performance for a XPage application.
Most of them taken from Steve Castledine.

Increasing the possible workload of the server


XPages are using Java in the background, and the amount of memory Java can consume in the Domino server is limited by the HTTPJavaMaxHeapSize notes.ini parameter. Check the technote at http://www-01.ibm.com/support/docview.wss?uid=swg21377202 for the latest recommendations and default values.

Set on the server console via
set configuration HTTPJavaMaxHeapSize=512M

Storing large amount of data in a scoped variable


Prefer java objects instead of javascript objects, for example use a java.lang.hashMap instead of a JavaScript array.
Doesn't matter for small amounts of data, only if you want to store many values.

Use partial refresh


If you change something on your page, use a partial refresh instead of a full refresh since partial refreshes only need to process a subset of the JSF tree and are therefore faster.

JavaScript variables


In 8.5.0 think about setting your variables to null when you don't need them anymore.
It is planned in 8.5.1 to have a setting so that all variables are cleared automatically after the lifecycle of a request.

General tips


Blog post of Mark Gargan: http://xpagesblog.com/xpages-blog/2009/8/10/writing-efficient-scalable-xpages.html

Synchronized functions and caching


Matt White wrote about an interesting technique to optimize performance for frequently used functions, see the full post here: http://mattwhite.me/blog/2009/9/14/on-synchronization-in-xpages.html

In a nutshell: you can mark a block of code as 'synchronized' which means that it is not allowed to run concurrently when mutiple clients are doing the same.
A synchronized function is ideal to compute expensive stuff and cache it.

Here an example an example function which computes something expensive and caches the result. If the result is already in the cache, it is returned immediately.
A cached result expires after some time.

function getExpensiveResult(){
  synchronized(applicationScope) {
    if(isCacheInvalid("example_key", 600)) {
       result = // do expensive computation of something, like iterating through a view or so       
       applicationScope.put("example_key", result);
  } 
  }
  return applicationScope.get("example_key");
}

/**
A generic caching mechanism for each key will check to see if it is 'n' seconds
since it was last updated. Use for things that change relatively infrequently  
*/
function isCacheInvalid(key, cacheInterval){
var currentTime = new Date().getTime();
if (!applicationScope.containsKey(key + "_time")){
applicationScope.put(key + "_time", currentTime);
  return true;
}

var diffInSecs = Math.ceil((currentTime - applicationScope.get(key + "_time")) / 1000);
if (diffInSecs < cacheInterval) {
return false;
} else {
applicationScope.put(key + "_time", currentTime);
return true;
}
}


Use recycle methods


When running through a large set of Notes objects like with NotesDocumentCollection.getFirst(), getNext() watch the memory consumption of your HTTP task.
Since there are Java objects behind the JavaScript objects, then have the same requirement to call recycle() to remove them from memory.

Read Domino Designer help regarding recycle() methods of Notes Java objects.

Use firebug page speed


In Firefox you can add an extension to your firebug: page speed.
This tool check where your website is slow and why. Very valuable.
See what's possible with Xpages.
Have a look at our ServiceCommunicator website
and the YouAtNotes Support.
Use  searchlotus.com  for news in the Web related to Lotus Notes and Domino,
and to search those sites.
Check  youatnotes.com  for great Lotus Notes, Domino and XPages software.
Did this wiki help you?
Did this saved you time? Express your gratitude by making a donation:
PayPal - The safer, easier way to pay online!