I decided to find a demonstration program that works
similar enough to FOP that I could try the String.intern()
technique.
1) SAXTreeValidator.java from Chapter 3 of Brett McLaughlin's
"XML and Java" the online copy of the example is 2nd Ed.
2) Fed this program various fragments of .fo files I have
accumulated lately.
3) There was one line I had to change in the program
Line 355: if (attPrefix == null || attPrefix.equals("")) {
had to add test for null as the prog threw NPE.
4) Changed the handling of strings at the for-loop storing the
attributes received from the parser in startElement( ... )
// Process attributes
for (int i=0; i<atts.getLength(); i++) {
DefaultMutableTreeNode attribute =
new DefaultMutableTreeNode(("Attribute (name = '" +
atts.getLocalName(i) +
"', value = '" +
atts.getValue(i) +
"')").intern() );
So I intern these strings rather than storing new strings.
5) Tested this program with this particular call to 'intern'
enabled and disabled. With my 'defguide.fo' file from
styling "DocBook: The Definitive Guide"
The results:
interned attributes: 87M reported by 'top' in column RSS
non-interned strings 184M reported by 'top'
6) Speed was about the same ('time' reported 27 and 30 second 'user')
7) I ran a similar test in the JMP profiler with a much smaller
.fo file. AT the end of execution I determined that the heap
was about 4.8M for the non-interned code and 2.8M for the interned.
Conclusion: Interning strings in FOP will help. I believe the code
to change is in FOTree.java.
I will code up an example and test it in a day or so.
--
John Austin <[EMAIL PROTECTED]>