5 Replies Latest reply on Feb 1, 2011 4:58 AM by dmitry.kudrenko

    uicomponent tree memory usage

    dmitry.kudrenko

      Greetings,

       

      I have rich faces application (3.3.2.SR1). The application uses ModelPanel to view entities. All modal panels are not rendered until I want to show them (rendered = false). Application becomes to be big, and uses a lot relations from one panel to others. All works fine, but it looks like richfaces creates UIComponent tree in memory for all possible cases if component rendred is true or false. When I tried to check memory usage of application (I used YourKit Java Profiler for these needs) I see that it uses a lot of memory for one session.

       

      I am using Facelets together with richfaces and I tried to use <c:if test="rendred condition"... It starts to use significantly less memory, but...

      when I rerender the area with panel, controls on parent screen are stopped to work. I suspect that it is because of every time when component tree is changed it recreates whole tree, and I have unsynchronized client (html) and server (faces) parts.

       

       

      Could somebody suggest me the way how to reduce memory usage? I have real problem with it as StandardSession object in HeapMemory uses 60-150Mb. And almost all of this memory used for UIControls.

       

       

      Example of the problem:

       

      I have page which has to panel1, panel2, panel3.

       

      Panel is:

       

          <rich:modalPanel >

              <a4j:outputPanel layout="block"

                       rendered="#{PanelBeanHolder.renderedViewScreen}">

                  <ui:insert name="panelContent" />

              </a4j:outputPanel>

          </rich:modalPanel>

       

      I am rendering panel only when action for this is performed. And do not want to load the UI controls for output panel until I need it.

       

      Thank you in advance.

        • 1. uicomponent tree memory usage
          mp911de

          Do you have one Page with all your Modal-Panels? Have you tried to split those on multiple pages?

          • 2. uicomponent tree memory usage
            dmitry.kudrenko

            I have a lot of pages. But I also has a lot of popups on each page. For example: I have list of Customers with ability to view customer details in a popup, and so on, and for Edit Customer I have several popups to select Address, some Attachments, etc...

            • 3. uicomponent tree memory usage
              ilya_shaikovsky

              It's better to use single panel but load different subviews via ajax like there:

                  <rich:modalPanel >

                      <a4j:outputPanel layout="block" id="lp">

                          <ui:include src="#{pagecontroller.currentPane}"/>

                      </a4j:outputPanel>

                  </rich:modalPanel>

              ...

              <a4j:command reRender="lp" action="#{pagecontroller.setEditPane}" oncomplete="#{r:component('paneId')}.show()">

               

              <a4j:command reRender="lp" action="#{pagecontroller.setViewDetailsPane}" oncomplete="#{r:component('paneId')}.show()">

              • 4. uicomponent tree memory usage
                dmitry.kudrenko

                Thank you for reply. But unfortunately it doesn't work for me. I tried to explain the same problem in the original post  based on <c:if example.

                 

                Your example works only partially. The problem that when lp panel is rerendered it generates new UI component tree, and a4j:controls will stop work when modal panel is generated first time, because of html part and server view are unsynchronized.

                 

                It can start work if you will rerender area with these controls onClose event for this modalPanel. But it doesn't look like proper solution.

                • 5. uicomponent tree memory usage
                  dmitry.kudrenko

                  I tried to do the following to improve the situation

                   

                  Configure number of views in session inside web.xml with:


                  <context-param>

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

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

                   

                  It has to improve StateHolder object, but it doesn't help a lot. I did measuring and memory usage is grows when these number are grow. But, when i tired to set them to 1,1 - some pages stopped work. Sometimes request is forwarded to the welcome page. 2,2 improved the situation, but the issue with forwarding to welcome pages still happens.

                   

                   

                  Tried to use client mode in javax.faces.STATE_SAVING_METHOD. It still uses a lot of memory for UIComponent model. Even if objects are serialised and have to be stored in the form.

                   

                  Tried to rewrite stateManagerin faces.config:

                  <state-manager>org.ajax4jsf.application.CompressAjaxStateManager</state-manager>

                  and rewrite buildViewState and restoreView for compressing the stream. It doesn't help a lot.