I have modified the parser to reduce memory footprint
and improve performance. Both goals achieved quite
nicely. What I did was simple: data structures to keep
children and attributes are not instantiated until
need. The logic behind it is simple: most nodes or at
least 50% have no children (all "leaves" of the tree)
and often no attributes. That's it. Rather simple.
The modified file attached. The changes are well
tested. Using for many months, now, in production
environment.
Also, added a few convenience methods like getChild(name).
Details on performance/footprint:
Test data file: 10,000 nodes. One parent with 10,000
children, each with a string contents and nothing else.
* Original code required 9MB and took 5,388 ms to read
the file.
* After changes applied: 2300KB and 4,700 ms.
Stan Berka
Pope & Talbot, Inc.
Portland, OR
Modified XMLElement.java