[jdom-interest] JDOM parser reuse memory problem

Randall Theobald randallt at us.ibm.com
Fri Nov 11 04:31:38 PST 2011

I'd vote for a proper fix of properly resetting the XMLReader at the end of
the build method. Our product is stuck on 1.0-beta-7 or something which
doesn't even have the parser reuse in it yet, so there is no hurry. I just
wanted to make sure that the issue got looked at moving forward.
   Randall Theobald                                   
   Performance: WebSphere                             
   Business Process                                   
   Management &                                       
   IBM Software Group             randallt at us.ibm.com 
   Austin, TX                     512-286-8870   t/l: 

From:	Rolf Lear <jdom at tuis.net>
To:	Michael Kay <mike at saxonica.com>,
Cc:	jdom-interest at jdom.org
Date:	11/11/2011 05:31 AM
Subject:	Re: [jdom-interest] JDOM parser reuse memory problem
Sent by:	jdom-interest-bounces at jdom.org

On 11/11/2011 3:33 AM, Michael Kay wrote:
> On 10/11/2011 18:51, Rolf Lear wrote:
>> Hi Randall, Michael.
>> It's an interesting observation... and I can see the implications. I
>> would
>> like to take a closer look at at, but that may take a little while.
>> I filed https://github.com/hunterhacker/jdom/issues/52
>> 'Off the cuff' I can think of one work-around and a few solutions (in
>> addition to what Michael has suggested)
>> 1. immediately after parsing your real document you then parse a
>> dummy/small/inmemory document (even invalid - and catch the exception).
>> 2. Currently when you do-no reuse the parser, it goes back to 'first
>> principals' and queries JAXP, etc. to find a parser instance Instead it
>> could 'cache' the parser 'source' after the first time, and then just
>> create a new instance, instead of doing all the class-based lookups...
> Ouch. Creating a new parser to parse a small document is a cost that
> it's nice to avoid, but it isn't going to kill you. Going through the
> JAXP factory process to get a new ParserFactory is a monstrous cost
> that can dominate all other processing - and reusing the factory costs
> nothing.
> Michael Kay
> Saxonica
Not sure what you are saying... are you agreeing that the 'ouch' problem
is the one it has at the moment, or the suggestion to skip the JAXB
processing on subsequent non-reuse-parser parses?

I have not yet had a close look at the problem... the potential option
of not going back to first-principles on subsequent parses may not be
(easily) possible.... Unless Randall can convince me otherwise, I'm
going to finish working on some StAX outputter code I am embroiled in,
and then look at it.

To control your jdom-interest membership:

More information about the jdom-interest mailing list