xerces-c-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Bertoni <dbert...@apache.org>
Subject Re: Right usage of xerces
Date Wed, 15 Jul 2009 18:03:22 GMT
Altman, Drora wrote:
> Hi,
> We have a project that uses xerces (2.8.0) in order to parse xml files. We allocate the
data as a DOM object in memory and work on it (adding/deleting nodes).
> The xml are quiet big.
> It seems that we miss something in the right usage of xerces, since the application consumes
a lot of memory and it does not seem to be released properly.
> During our investigation of the code, I realized that the code uses the importNode function,
which, as far as I understand, allocates the memory. This brings me to the following questions:
> 1. What's the difference between the importNode() & cloneNode() functions?
importNode() essentially clones a node from another document so you can 
add it to the target document.

> 2. How can we actually delete the memory allocated by import\cloneNode if we delete this
node afterwards?
All of the memory for nodes is allocated from a pool owned by the 
document instance. There is no way to recover memory for individual nodes.

> 3. What are your general recommendations, regarding cleanup memory at the end of the
usage of xerces?
If your usage model involves creating and releasing lots of nodes, you 
might want to consider "compacting" a document by cloning the entire 
document node and releasing the original document. If you created the 
original document using a parser, remember the document instance itself 
is owned by the parser, unless you call adoptDocument() on the parser 


View raw message