You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Antonio Petrelli (JIRA)" <ji...@apache.org> on 2007/09/18 13:04:36 UTC

[jira] Resolved: (STR-1333) [tiles] excessive memory usage

     [ https://issues.apache.org/struts/browse/STR-1333?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Antonio Petrelli resolved STR-1333.
-----------------------------------

       Resolution: Won't Fix
    Fix Version/s:     (was: Future)
         Assignee:     (was: Struts Developers)

This improvement consists of a major refactoring of the code. Since the refactoring has been made in Tiles 2, it is not necessary to do it again in Tiles 1.

> [tiles] excessive memory usage
> ------------------------------
>
>                 Key: STR-1333
>                 URL: https://issues.apache.org/struts/browse/STR-1333
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Tiles 1 Plugin
>    Affects Versions: 1.1 RC1
>         Environment: Operating System: All
> Platform: All
>            Reporter: Christophe Warland
>            Priority: Minor
>         Attachments: patch-tiles-component-delegation.txt
>
>
> The implementation of component definition inheritance in Tiles is based on a
> deep-copy of all attributes in a parent's map. This systematic deep copy is very
> memory consuming and should be replaced by delegation between
> ComponentDefinition instances at runtime.
> My company has updated the copy of Tiles that it uses in production (dated
> 2001-09-11) so that delegation actually occurs at runtime between the 668
> component definitions that we use in our system. This simple change allows us to
> save more than 50 MB of ram. 
> We actually have 7037 attributes defined in XML files. As mentionned above, the
> original Tiles requires more than 50 MB of RAM to load them and store them in
> HashMaps. However, since HashMap entries take only 24 bytes in memory, Tiles
> should in theory only need 7037 * 24 = 165k to load them. This is exactly what
> the proposed change does.
> [More on this can be read in the following thread:
> http://nagoya.apache.org/eyebrowse/BrowseList?listName=struts-dev@jakarta.apache.org&by=thread&from=336559&to=336559&first=1&count=7
> ]
> In summary, to update Tiles, you should take the following approach:
> 1. go to ComponentDefinition and ComponentContext and delete the following
> dangerous methods
>     public Map getAttributes()
>     public ComponentContext(Map attributes)
>     public void addAll(Map newAttributes)
>     public void addMissing(Map defaultAttributes)
> 2. then refactor/recompile/refactor the rest of Tiles until you have something
> usable (pass along and keep track of ComponentDefinition objects as much as you
> can -- never access the HashMap directly).
> It worked very well for us. Our patch, which is based on Tiles 2001-09-11 is
> attached, to this bug report.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.