Oops. Alberto already corrected the first point. I stand by the second,
though.

________________________________

From: Jesse Pelton [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 27, 2008 8:59 AM
To: [email protected]
Subject: RE: Please help me out with this code..Can i reuse DOM objects
in a while loop??????


I haven't examined the reset code, but I'd expect the document to be
released when you reset the parser (unless you adopt the document via a
call to adoptDocument(), in which case it's your responsibility to
release it).
 
Given that you're processing huge files, you should consider using a SAX
parser. SAX is a stream-oriented interface. You install callbacks to
handle SAX events as the input is processed. You use the callbacks to
extract whatever information you need and store it however it makes
sense; the parser does not construct any representation of the document
itself. If you store the extracted data efficiently, this should require
much less memory than a DOM representing the entire document. In the
ideal case, you have chunks of data that can be processed and then
discarded; a SAX parser should be able to handle arbitrarily large
documents in this scenario, assuming the chunks aren't so big that they
exhaust memory.

________________________________

From: Sree Harsha [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 26, 2008 10:20 PM
To: [email protected]
Subject: Re: Please help me out with this code..Can i reuse DOM objects
in a while loop??????


Thanks for your reply, but still the memory consumption has not come
down. Is there any way i can reuse DOMDocument variable also like in the
following snippet...
 
do 
{ 

/*create a source file */ 

parser_.parse(source); //parser_ is a XercesDOMParser object 
 
xercesc::DOMDocument* xmlDoc = parser_.getDocument() ;

/*How to release the memory allocated to the DOMDocument pointer*/

/*parse the file source*/ 

/*delete the source file*/ 

/*I used the function which you suggested*/
 
parser_.reset();
 
/*still it takes up a lot of memory when parsing a big file*/

}while(dwbytes==bufsize); 
/*some condition*/ 

Finally I also have one more doubt... When we use DOM, the entire file
to be parsed is brought into the memory isnt it... Now if I have to
parse a large file, say 380 MB or 1GB, we cant Bring the entire file to
the memory. So I thought it would be better to split the file into
smaller sizes and parse them bit by bit (4K long)... that is the reason
i have used create source file in the above code....
Am I in the Right path????
 
On 2/26/08, Jesse Pelton <[EMAIL PROTECTED]> wrote: 

        It looks to me like you could call the various
XercesDOMParser::reset...() and AbstractDOMParser::reset...() methods.
Or, to be paranoid and/or lazy, you could use a new parser for each
iteration.

________________________________

        From: Sree Harsha [mailto:[EMAIL PROTECTED] 
        Sent: Tuesday, February 26, 2008 5:40 AM
        To: [EMAIL PROTECTED]; [email protected]
        Subject: Please help me out with this code..Can i reuse DOM
objects in a while loop??????
        
         
        
        
        /*Can i reuse the DOM objects like XercesDOMParser object in a
do... while loop as follows.... or will it cause any memory leaks how to
reuse them...*/ 
        do 
        { 
        
        /*create a source file */ 
        
        parser_.parse(source); //parser_ is a XercesDOMParser object 
        
        /*parse the file source*/ 
        
        /*delete the source file*/ 

        /*what function should i call to reuse parser_ object in the
next iteration so that memory consumption reduces */

        }while(dwbytes==bufsize); 
        /*some condition*/ 

        
        -- 
        Regards
        Sree Harsha Vardhana S.N
        "When you want something, all the universe conspires in helping
you to
        achieve it." 
        
        -- 
        Regards
        Sree Harsha Vardhana S.N
        "When you want something, all the universe conspires in helping
you to
        achieve it." 




-- 
Regards
Sree Harsha Vardhana S.N
"When you want something, all the universe conspires in helping you to
achieve it." 

Reply via email to