ICEfaces
  1. ICEfaces
  2. ICE-3441

Memory: EL strings need to be pooled/reused in JSP

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.1
    • Fix Version/s: 1.8DR#1, 1.8
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      Any

      Description

      We are wasting some amount of memory per client with every EL expression. We are using 5,160 bytes in string objects per client in both auction monitor and address demo (coincidentally it's the same amount). We are keeping in memory strings like "#{AuctionBean.sortByTitle}" for every client, while the value is the same and never changes. This doesn't happen with standard JSF or facelets, only when using JSPs.

      Both standard JSF and ICEfaces use a group of objects from the org.apache.el.parser package to store EL expressions. Only one set of these objects is necessary for each EL expression in a document. The number of instances of these objects is not proportional to the number of clients accessing a document in both standard JSF and ICEfaces. The problem is that ICEfaces references these objects indirectly through other three objects, and one of those objects stores the entire string of the EL expression. This is being done on a per-client basis.

      A concrete example would illustrate this better. Consider the following EL expression: "#{AuctionBean.sortByTitle}". The servlet container (in this case Tomcat 6) represents this expression with an AstValue object (from org.apache.el.parser), and this object has two children: AstIdentifier, which stores the string "AuctionBean", and AstDotSuffix, which stores the string "sortByTitle". Only one set of these objects is created per EL expression in a document. ICEfaces does the following. An HtmlCommandLink object, from the 'actionExpression field', references an instance of MethodExpressionMethodBindingAdapter (from javax.faces.component), whose sole job is to reference an instance of MethodBindingMethodExpressionAdapter (from com.sun.faces.application), which in turn references an instance of MethodExpressionImpl (from org.apache.el). This last object finally references the AstValue object mentioned above, but also has a String object with the value "#{AuctionBean.sortByTitle}". This is done for every client for every EL expression, and the string is not in constant pools and is not shared by
      other EL related objects, even if the value is the same.

      In facelets, things are different. For example, a`component object has a hash map called 'bindings'. The values of this hash map are TagValueExpression objects (from com.sun.facelets.el). These objects reference orig ValueExpressionImpl objects (from org.apache.el), as above. However, these ValueExpressionImpl objects reference the same string object when the EL expression is the same.

        Issue Links

          Activity

          Hide
          Arturo Zambrano added a comment -

          This is the way EL values are being referenced from the component object to the object where the servlet container stores EL values.

          javax.faces.component.ValueExpressionValueBindingAdapter
          com.sun.faces.application.ValueBindingValueExpressionAdapter
          org.apache.el.ValueExpressionImpl
          org.apache.el.parser.AstValue
          (EL expression String)

          javax.faces.component.MethodExpressionMethodBindingAdapter
          com.sun.faces.application.MethodBindingMethodExpressionAdapter
          org.apache.el.MethodExpressionImpl
          org.apache.el.parser.AstValue
          (EL expression String)

          javax.faces.component.MethodBindingValueChangeListener
          com.sun.faces.application.MethodBindingMethodExpressionAdapter
          org.apache.el.MethodExpressionImpl
          org.apache.el.parser.AstValue
          (EL expression String)

          Show
          Arturo Zambrano added a comment - This is the way EL values are being referenced from the component object to the object where the servlet container stores EL values. javax.faces.component.ValueExpressionValueBindingAdapter com.sun.faces.application.ValueBindingValueExpressionAdapter org.apache.el.ValueExpressionImpl org.apache.el.parser.AstValue (EL expression String) javax.faces.component.MethodExpressionMethodBindingAdapter com.sun.faces.application.MethodBindingMethodExpressionAdapter org.apache.el.MethodExpressionImpl org.apache.el.parser.AstValue (EL expression String) javax.faces.component.MethodBindingValueChangeListener com.sun.faces.application.MethodBindingMethodExpressionAdapter org.apache.el.MethodExpressionImpl org.apache.el.parser.AstValue (EL expression String)

            People

            • Assignee:
              Unassigned
              Reporter:
              Arturo Zambrano
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: