Re: Please help me out with this code..Can i reuse DOM objects in a while loop??????

2008-02-27 Thread Sree Harsha
Thanks Alberto,
I used resetDocumentPool(),
But I get a run time error R6025 pure virtual function call.

Thanks and regards
Sree Harsha Vardhana S.N

On 2/27/08, Alberto Massari [EMAIL PROTECTED] wrote:

 Hi Sree,
 you should invoke resetDocumentPool(), not reset(). As for the code you
 posted previously, I noticed you were not releasing the transcoded
 strings (you actually commented the call to XMLString::release): that
 would be a substantial leak.
 On the other hand, if you want to parse files so big, you should
 investigate switching to SAX parsing.

 Alberto

 Sree Harsha wrote:
  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] mailto:[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]
  mailto:[EMAIL PROTECTED]]
  *Sent:* Tuesday, February 26, 2008 5:40 AM
  *To:* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED];
  c-dev@xerces.apache.org mailto:c-dev@xerces.apache.org
  *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.



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




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


Re: Please help me out with this code..Can i reuse DOM objects in a while loop??????

2008-02-27 Thread Sree Harsha
Thanks for the tip on releasing the XMLstring memory ... there was a
reduction in the use of memory...
please tell me why i am getting an error when i resetDocumentPool();
I get a run time error R6025 pure virtual function call
thank you

On 2/27/08, Sree Harsha [EMAIL PROTECTED] wrote:

 Thanks Alberto,
 I used resetDocumentPool(),
 But I get a run time error R6025 pure virtual function call.

 Thanks and regards
 Sree Harsha Vardhana S.N

  On 2/27/08, Alberto Massari [EMAIL PROTECTED] wrote:
 
  Hi Sree,
  you should invoke resetDocumentPool(), not reset(). As for the code you
  posted previously, I noticed you were not releasing the transcoded
  strings (you actually commented the call to XMLString::release): that
  would be a substantial leak.
  On the other hand, if you want to parse files so big, you should
  investigate switching to SAX parsing.
 
  Alberto
 
  Sree Harsha wrote:
   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] mailto:[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]
   mailto:[EMAIL PROTECTED]]
   *Sent:* Tuesday, February 26, 2008 5:40 AM
   *To:* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED];
   c-dev@xerces.apache.org mailto:c-dev@xerces.apache.org
   *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.
 
 
 
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
 
 


 --
 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.


Re: Please help me out with this code..Can i reuse DOM objects in a while loop??????

2008-02-27 Thread Alberto Massari

Sree Harsha wrote:

Thanks Alberto,
I used resetDocumentPool(),
But I get a run time error R6025 pure virtual function call.


When/where do you call resetDocumentPool? And where do you get the pure 
virtual function call? Are you attempting to access one of the DOM tree 
that you have just released?


Alberto

 
Thanks and regards

Sree Harsha Vardhana S.N
 
On 2/27/08, *Alberto Massari* [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED] wrote:


Hi Sree,
you should invoke resetDocumentPool(), not reset(). As for the
code you
posted previously, I noticed you were not releasing the transcoded
strings (you actually commented the call to XMLString::release): that
would be a substantial leak.
On the other hand, if you want to parse files so big, you should
investigate switching to SAX parsing.

Alberto

Sree Harsha wrote:
 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] mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] mailto:[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]
mailto:[EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]]
 *Sent:* Tuesday, February 26, 2008 5:40 AM
 *To:* [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED];
 c-dev@xerces.apache.org mailto:c-dev@xerces.apache.org
mailto:c-dev@xerces.apache.org mailto:c-dev@xerces.apache.org
 *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.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]




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




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Please help me out with this code..Can i reuse DOM objects in a while loop??????

2008-02-27 Thread Sree Harsha
XercesDOMParser parser_;

do
 {

/*create a source file */

/*During the next iteration the following code will give runtime error*/


parser_.parse(source);


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_.resetDocumentPool();

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



On 2/27/08, Alberto Massari [EMAIL PROTECTED] wrote:

 Sree Harsha wrote:
  Thanks Alberto,
  I used resetDocumentPool(),
  But I get a run time error R6025 pure virtual function call.

 When/where do you call resetDocumentPool? And where do you get the pure
 virtual function call? Are you attempting to access one of the DOM tree
 that you have just released?

 Alberto

 
  Thanks and regards
  Sree Harsha Vardhana S.N
 
  On 2/27/08, *Alberto Massari* [EMAIL PROTECTED]
  mailto:[EMAIL PROTECTED] wrote:
 
  Hi Sree,
  you should invoke resetDocumentPool(), not reset(). As for the
  code you
  posted previously, I noticed you were not releasing the transcoded
  strings (you actually commented the call to XMLString::release):
 that
  would be a substantial leak.
  On the other hand, if you want to parse files so big, you should
  investigate switching to SAX parsing.
 
  Alberto
 
  Sree Harsha wrote:
   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] mailto:[EMAIL 
  PROTECTED]
  mailto:[EMAIL PROTECTED] mailto:[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]
  mailto:[EMAIL PROTECTED]
   mailto:[EMAIL PROTECTED]
  mailto:[EMAIL PROTECTED]]
   *Sent:* Tuesday, February 26, 2008 5:40 AM
   *To:* [EMAIL PROTECTED]
  mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
  mailto:[EMAIL PROTECTED];
   c-dev@xerces.apache.org mailto:c-dev@xerces.apache.org
  mailto:c-dev@xerces.apache.org mailto:c-dev@xerces.apache.org
   *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
   

Re: Please help me out with this code..Can i reuse DOM objects in a while loop??????

2008-02-27 Thread Sree Harsha
/*Here is how the code looks like*/

XercesDOMParser parser_;

do
 {

/*code to create a source file */

/*During the next iteration the following code will give runtime error*/


parser_.parse(source);


xercesc::DOMDocument* xmlDoc = parser_.getDocument() ;

/*code to parse the file source*/


/*code to delete the source file*/

/*I used the function which you suggested*/

parser_.resetDocumentPool();

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


RE: Please help me out with this code..Can i reuse DOM objects in a while loop??????

2008-02-27 Thread Jesse Pelton
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: c-dev@xerces.apache.org
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]; c-dev@xerces.apache.org
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. 


Re: Please help me out with this code..Can i reuse DOM objects in a while loop??????

2008-02-26 Thread Sree Harsha
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]; c-dev@xerces.apache.org
 *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.