xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Clark <an...@apache.org>
Subject Re: Performance and thread safety in Xerces
Date Wed, 28 Jun 2000 20:30:17 GMT
Dennis Thrysoe - Netnord A/S wrote:
> I my concrete case I have some code that calls ElementImpl.getAttribute()
> about 320,000 times. This code takes a bit long, and creates a total of
> almost 600,000 objects.

I would imagine that your 600,000 objects come from the fact that
the getAttribute method has to concatenate the children of the
attribute node in order to return you a string. So save the 
memory you should use getAttributeNode and then query the
children yourself.

> The other thing relates to the thread safety of Xerces. I have two seperate
> threads parsing two different XML files. Still I seem to get race conditions
> on some arrays:

Access to the parser and the DOM are *not* thread-safe. You still
have to manage locks in order to ensure that multiple threads are

  1) not using the parser at the same time
  2) not editing a DOM document at the same time

Now, if there are static members that are used in the code and
access to them is not synchronized, then that could be causing
the race condition problems that you are seeing. Let us know if
you deduce the cause of your problem.

Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org

View raw message