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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to