WebSphere Portal and JSF Memory Woes

If you use WebSphere Portal and JSF (Java Server Faces) and having issues with memory, garbage collection and slow performing Portal then you may want to review your JSF settings in your web.xml.  JSF is known to be a memory hog. By default it maintains 15 view states on the server side. These states are stored in user session and may last considerable amount of time on applications that require users to be logged in for the complete work day schedule. We found out on a typical 2GB heap size JVM, about 800 MB of memory is held by these JSF view states.  You can configure the number of “view states to save” in your web.xml file of your portal application.

Check out this tech note on details on changing the default number of view states saved from 15 to a lower number.   – https://www-304.ibm.com/support/docview.wss?uid=swg21424426

We set  the number of view states  to 2 (from the default 15) and were surprised to find the reduction in session memory from 800 MB to to about 200 MB over 6-8 hour period. That was considerable savings on memory.

You can use the IBM Support Assistant – a free tool from IBM that provides a number of JVM problem analysis tool including a memory analyzer that enables you to look at heap dumps, thread dumps, logs etc. You can download this tool from the following location –   IBM Support Assistant

You can use the memory analyzer tool to inspect heap dumps  before and after changing this configuration and compare the memory usage by the key erring class that keeps the memory in session –  com.sun.faces.util.LRUMap. Attached are some screen shots on our findings.

Data using the default view states of 15:

Heap Distribution and com.sun.faces.util.LRUMap instance data

– Notice about 800 MB chunk of heap data that is attributed to com.sun.faces.util.LRUMap classes instances

Heap Data with default number of view states - 15
Heap Data with default number of view states - 15
instances and memory held by com.sun.faces.util.LRUMap  class
Instances and memory held by com.sun.faces.util.LRUMap class with default view states - 15

Data using the view states set to 2:

Heap Distribution and com.sun.faces.util.LRUMap instance data

– Notice that the amount of memory held has now come down to about 200 MB

Heap distribution with JSF states set to 2
Heap distribution with JSF states set to 2
Instances and memory held by sun.com.faces.util.LRUMap with JSF states set to 2
Instances and memory held by sun.com.faces.util.LRUMap with JSF states set to 2