[jdom-interest] Namespaces accumulation bug in SAXHandler

Jason Hunter jhunter at servlets.com
Tue Jun 12 22:25:22 PDT 2001

Are you using the latest code in CVS?  I'm believe we fixed this


> "Alexander A. Rudnev" wrote:
> Hi, I've encountered some problem with performance and found that
> possible reason (most probably it is not important and I'm wrong here,
> I'll figure it out tomorrow, but anyway, it's kind of
> performance/memory leak) is managing of "availableNamespaces" in
> SAXHandler. For example, if we declare some namespace in the root
> element and then all nested elements have this namespace, then for
> every nested element new copy of the namespace will be added to the
> "availableNamespaces" and will not be removed from it until the end of
> the parsing process. This is because element's namespace is added to
> the "availableNamespaces" every time on "startElement", but only
> "additionalNamespaces" are removed on "endElement".
> Possible fix is to add element's namespace conditionally, say in such
> a way
>  public void startElement(String namespaceURI, String localName,
>         String qName, Attributes atts)
>         throws SAXException {
> ...
>    // Remove this namespace from those in the temp declared list
>    if (declaredNamespaces.size() > 0) {
>     if(declaredNamespaces.remove(elementNamespace)) {
>      // It's now in available scope
>      availableNamespaces.addFirst(elementNamespace);
>     }
>    }
> ...
> , but actually I did not think about it a lot.
> Thanks.

More information about the jdom-interest mailing list