I'm using Dom4J 1.4.2.
Right now my code creates a new SaxReader every time I want to parse a new XML document:
SAXReader reader = new SAXReader( );
Is there any value in creating a pool of SaxReader objects and just reusing them? How much overhead is involved in creating a new SaxReader on every call?
My code could get one from the pool, parse the document then return it to the pool for another thread to use.
As with all so-called performance issues and urges to pool objects: are you experiencing an actual problem, or are you trying to prematurely optimize here? Rolling your own pooling in Java has been out of fashion since at least 2005.
I peeked at the source code of SAXReader, and this is the constructor:
138 public SAXReader() {
139 }
There are no instance initializers, and the real work is done in the read
method.