You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Raghu Nandan <rn...@us.ibm.com> on 2003/03/03 18:32:24 UTC
Process Growth
Folks:
In order to test performance when handling xml scripts,
I modified the sample program given in the programming
guidelines so that it looped over calls to the parser.
To make matters simple, I just used the same xml script
for each iteration.
I notice that there is a significant growth in process size as
reported by the "ps au" command. I have tried this on
aix 5.2 using visual age 6.0 compiler with Xerces-c++ version 2.1
as well as on SuSE linux 8.0 professional with Xerces c++ version
2.2.
Here is the sample code:
#include <xercesc/parsers/XercesDOMParser.hpp>
#include <xercesc/dom/DOM.hpp>
#include <xercesc/sax/HandlerBase.hpp>
#include <xercesc/util/XMLString.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <iostream>
using namespace std;
int main (int argc, char** args)
{
try {
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch) {
char* message = XMLString::transcode(toCatch.getMessage());
cout << "Error during initialization! :\n"
<< message << "\n";
delete [] message;
return 1;
}
XercesDOMParser* parser = new XercesDOMParser();
parser->setValidationScheme(XercesDOMParser::Val_Always); // optional.
parser->setDoNamespaces(true); // optional
ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase();
parser->setErrorHandler(errHandler);
char* xmlFile = "sample2.xml";
try {
cout << "priming" << endl;
parser->reset();
parser->resetDocumentPool(); //Is this required
parser->parse(xmlFile);
}
catch (const XMLException& toCatch) {
char* message = XMLString::transcode(toCatch.getMessage());
cout << "Exception message is: \n"
<< message << "\n";
delete [] message;
return -1;
}
catch (const DOMException& toCatch) {
char* message = XMLString::transcode(toCatch.msg);
cout << "Exception message is: \n"
<< message << "\n";
delete [] message;
return -1;
}
catch (...) {
cout << "Unexpected Exception \n" ;
return -1;
}
for (;;) {
cout << "before parse" << endl;
parser->reset();
parser->parse(xmlFile);
cout << "after parse" << endl;
}
delete parser;
delete errHandler;
return 0;
}
Has anyone else experienced similar problems?
Any help / pointers regarding which calls need to be made in order to
avoid process growth is welcome.
Thanks,
raghu
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
Re: Process Growth
Posted by PeiYong PY Zhang <pe...@ca.ibm.com>.
raghu,
It is the resetPool() u need to release the memory allocated for
the document parsed.
try {
parser->resetPool();
parser->parse(xmlFile);
}
Rgds,
PeiYong
----- Original Message -----
From: "Raghu Nandan" <rn...@us.ibm.com>
To: <xe...@xml.apache.org>
Sent: Monday, March 03, 2003 12:32 PM
Subject: Process Growth
>
>
>
>
>
> Folks:
>
> In order to test performance when handling xml scripts,
> I modified the sample program given in the programming
> guidelines so that it looped over calls to the parser.
> To make matters simple, I just used the same xml script
> for each iteration.
>
> I notice that there is a significant growth in process size as
> reported by the "ps au" command. I have tried this on
> aix 5.2 using visual age 6.0 compiler with Xerces-c++ version 2.1
> as well as on SuSE linux 8.0 professional with Xerces c++ version
> 2.2.
>
> Here is the sample code:
>
> #include <xercesc/parsers/XercesDOMParser.hpp>
> #include <xercesc/dom/DOM.hpp>
> #include <xercesc/sax/HandlerBase.hpp>
> #include <xercesc/util/XMLString.hpp>
> #include <xercesc/util/PlatformUtils.hpp>
> #include <iostream>
>
> using namespace std;
>
> int main (int argc, char** args)
> {
> try {
> XMLPlatformUtils::Initialize();
> }
> catch (const XMLException& toCatch) {
> char* message = XMLString::transcode(toCatch.getMessage());
> cout << "Error during initialization! :\n"
> << message << "\n";
> delete [] message;
> return 1;
> }
>
> XercesDOMParser* parser = new XercesDOMParser();
> parser->setValidationScheme(XercesDOMParser::Val_Always); //
optional.
> parser->setDoNamespaces(true); // optional
>
> ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase();
> parser->setErrorHandler(errHandler);
>
> char* xmlFile = "sample2.xml";
>
> try {
> cout << "priming" << endl;
> parser->reset();
> parser->resetDocumentPool(); //Is this required
> parser->parse(xmlFile);
> }
> catch (const XMLException& toCatch) {
> char* message = XMLString::transcode(toCatch.getMessage());
> cout << "Exception message is: \n"
> << message << "\n";
> delete [] message;
> return -1;
> }
> catch (const DOMException& toCatch) {
> char* message = XMLString::transcode(toCatch.msg);
> cout << "Exception message is: \n"
> << message << "\n";
> delete [] message;
> return -1;
> }
> catch (...) {
> cout << "Unexpected Exception \n" ;
> return -1;
> }
>
> for (;;) {
> cout << "before parse" << endl;
> parser->reset();
> parser->parse(xmlFile);
> cout << "after parse" << endl;
> }
>
> delete parser;
> delete errHandler;
> return 0;
>
> }
>
> Has anyone else experienced similar problems?
> Any help / pointers regarding which calls need to be made in order to
> avoid process growth is welcome.
>
> Thanks,
> raghu
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org