Affects Version/s: 1.1.1, 1.3.8
Fix Version/s: None
Component/s: Tiles 1 Plugin
Environment:AIX, Windows, WebSphere 6.1, DB2 9.5
During performance testing we discovered an Out of Memory exception. While looking into the heap dump produced, I detected two separate tiles objects (namely org.apache.struts.tiles.xmlDefinition.XmlParser and org.apache.struts.tiles.xmlDefinition.DefinitionsFactory) which combined were consuming 285 meg (we have a lot of tiles definitions). After further analysis of the code in org.apache.struts.tiles.xmlDefinition.I18nFactorySet, I discovered that for each tile config file being processed by org.apache.struts.tiles.xmlDefinition.I18nFactorySet.parseXmlFile(ServletContext servletContext, String filename, XmlDefinitionsSet xmlDefinitions) was creating a new XmlParser() to parse the tiles config file and put into an XmlDefinitionsSet. The new XmlDefinitionsSet is ultimately used to construct org.apache.struts.tiles.xmlDefinition.DefinitionsFactory. After the last file is processed the XmlParser is kept in memory and no longer performs the necessary function after initializing Tiles is complete. The underlying SAXParser and other objects are still there consuming resources.
I removed the following code from org.apache.struts.tiles.xmlDefinition.I18nFactorySet.
- XML parser used.
- Attribute is transient to allow serialization. In this implementaiton,
- xmlParser is created each time we need it ;-(.
protected transient XmlParser xmlParser;
And changed the following in the method parseXmlFile( ServletContext servletContext, String filename, XmlDefinitionsSet xmlDefinitions)
I've included a patch file with changes also.