Details
Description
Each hard-coded XHTML tag in a JSP document is generating a new string object instead of reusing a static/constant field containing the same value. For example, if a JSP documen has 50 hard-coded <div>'s, then 50 string objects with the value "div" will be created. Since this is being done for every client, it is consuming an important amount of memory.
It is important to note that each of these strings is referenced by 3 objects: an AttrImpl object (DOM), a UIXhtmlComponent object (component tree) and an XhtmlTag object (tag tree). It is also important to mention that XhtmlTag objects and IceOutputTextTag objects are being created on a per-client basis, when only one set of these objects is supposed to exist per document.
Moreover, certain tag objects especially XhtmlTag and IceOutputTextTag are being kept in memory per client. For example, with one client there are 15 CommandButtonTag objects, with two clients there are 25, with 3 clients there are 35, etc. There should be only one tag tree per document in the whole application.
It is important to note that each of these strings is referenced by 3 objects: an AttrImpl object (DOM), a UIXhtmlComponent object (component tree) and an XhtmlTag object (tag tree). It is also important to mention that XhtmlTag objects and IceOutputTextTag objects are being created on a per-client basis, when only one set of these objects is supposed to exist per document.
Moreover, certain tag objects especially XhtmlTag and IceOutputTextTag are being kept in memory per client. For example, with one client there are 15 CommandButtonTag objects, with two clients there are 25, with 3 clients there are 35, etc. There should be only one tag tree per document in the whole application.
Issue Links
- blocks
-
ICE-3083 Memory performance/efficiency
- Open
Activity
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion
The fix consists of adding to the parse() method of Parser.java the following code:
pageContext.removeAttribute(
"javax.faces.webapp.GLOBAL_ID_VIEW",
PageContext.REQUEST_SCOPE);
...right after:
pageContext.removeAttribute(
"javax.faces.webapp.COMPONENT_TAG_STACK",
PageContext.REQUEST_SCOPE);
This way, the additional tag objects and strings have no more incoming references, so they can be garbage collected.