Re: JDOM parser reuse memory problem

Rolf Lear <[email protected]>
Newsgroups gmane.comp.java.jdom.general
Message-ID <[email protected]>
On 17/11/2011 11:25 AM, BIHANIC Laurent wrote:
> Hi
>
> Le 17/11/11 17:01, Rolf Lear a écrit :
>> In a more generalized answer, the only issue I can see with having a pool of
>> SAXBuilders is that, if you reuse parsers, you will 'carry' the most recently
>> parsed document from each SAXBuilder until that builder is used again.
> It should not: the reference to the (being) built document is held by
> SAXHander and the reference to SAXHandler (contentHandler) is explicitely set
> to null at the end of the build() method in a finally clause.
>
> We did this because, in the past, we encountered some JVMs that were reluctant
> to garbage-collect the SAXHandler otherwise.
>
> Regards,
>
> Laurent
>
>

Hi Laurent.

Yeah, the code in the method indicates that (I was not aware it was you 
who put that in).

There is a bug though, and it could explain some confusion.

The problem is the the XMLReader has had it's various handlers set to 
the SAXHandler (Content, DTD, Error, etc.) and when you re-use the 
XMLReader, you in effect keep a reference to the SAXHandler.

Setting the SAXHandler to null at the end of the build does not cause 
the XMLReader to forget it's handlers.

It is an issue that Randall identified a week or so ago.

Rolf
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.