1 Reply Latest reply on May 29, 2011 9:35 AM by javatwo

    JSF memory leak: heap view

    javatwo

      Hi, I have a JSF web app using Richfaces, MyFaces and jsf ri running on JBoss 5.1.0.GA.

      JVM memory setting is :

       

      -Xms128M -Xmx1024M -XX:MaxPermSize=512M

       

      After running for a while, OutOfMemory error: java heap size and got a heap dump.

      Load the heap dump into JProfiler, the image attached.

       

      Total sessions: 50.

      Memory used by sessions: from 5M to 65M.

      session with 5M memory:  1 AjaxStateHodler$StateReference instance

      session with 65M memory: 12 AjaxStateHodler$StateReference instances

       

      web.xml

      -----------

        <context-param>
            <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
            <param-value>server</param-value>
        </context-param>

        <context-param>
           <param-name>com.sun.faces.numberOfViewsInSession</param-name>
           <param-value>5</param-value>
        </context-param>

        <context-param>
           <param-name>com.sun.faces.serializeServerState</param-name>
           <param-value>true</param-value>
        </context-param>

       

       

      the param "com.sun.faces.numberOfViewsInSession" is set to 5 in web.xml.

      it means max 5 views are saved in session. but for the sessions with 65M memory, it saved 12 views in session.

      Also, the param "com.sun.faces.serializeServerState" is set to true, view state is stored in memory?

       

      I expected the memory used by each JSF view state to be about 500K, but it was 5M.

      Thanks very much for any help identifying memory leak.

       

      Dave

        • 1. Re: JSF memory leak: heap view
          javatwo

          After setting the  com.sun.faces.numberOfLogicalViews to 2, limit the number of view states to be saved.

           

          <context-param>
                <param-name>com.sun.faces.numberOfViewsInSession</param-name>
                <param-value>2</param-value>
             </context-param>
            
             <context-param>
                <param-name>com.sun.faces.numberOfLogicalViews</param-name>
                <param-value>2</param-value>
             </context-param>  
               

          What is the relationship between logical views and views?  Actually what is logical views?

           

          From VisualVM memory monitor, the heap keeps growing even without any http requests. why?

          After perform GC, heap memory went down.

           

          Thanks,
          Dave