DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18237>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18237

Tiles excessive memory usage

           Summary: Tiles excessive memory usage
           Product: Struts
           Version: 1.1 RC1
          Platform: All
               URL: http://nagoya.apache.org/eyebrowse/BrowseList?listName=s
                    truts-
                    [EMAIL PROTECTED]&by=thread&from=336559&to=336559&f
                    irst=1&count=7
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Tiles framework
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


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/[EMAIL 
PROTECTED]&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.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to