I meant to say that the parser resources seems like its "not" getting
released.

Jason Jesso wrote:

> I have this program that enters an infinite loop.  It creates a parser
> and parses the xml file.  I then delete the parser using delete.  And so
> on, over and over again.
>
> Looking at the SZ column from ps (on AIX4.3.3) this number keeps
> increasing.  This suggests and memory leak or the parser resources are
> getting released.  I am calling delete on the parser.
>
> Can someone help?
>
> int
> main( int ac, char* av[] )
> {
>      DOMParser *parser;
>
>      if ( ac != 2 ){
>           cerr << "usage: " << av[0] << " xml file" << endl;
>           return 1;
>      }
>
>      try
>      {
>           XMLPlatformUtils::Initialize();
>      }
>      catch( const XMLException& e )
>      {
>           cerr << "Error during initialization! :\n"
>                << e.getMessage() << "\n";
>           return 1;
>      }
>
>      for ( ;; ){
>           parser = new DOMParser;
>           parser->setValidationScheme(DOMParser::Val_Always);
>           DOMTreeErrorReporter *errReporter = new
> DOMTreeErrorReporter();
>           parser->setErrorHandler(errReporter);
>
>           //
>           //  Parse the XML file, catching any XML exceptions that might
> propogate
>           //  out of it.
>           //
>           bool errorsOccured = false;
>
>           try
>           {
>                parser->parse( av[1] );
>                int errorCount = parser->getErrorCount();
>                if (errorCount > 0) errorsOccured = true;
>           }
>           catch( const XMLException& e )
>           {
>                cerr << "An error occured during parsing file: " << av[1]
> << endl << "Exception message is: " << endl << DOMString(e.getMessage())
> << endl;
>                errorsOccured = true;
>           }
>           catch (const SAXParseException& e)
>           {
>                cerr << "An SAXParseException error occured during
> parsing, got SAXParseException " << DOMString(e.getMessage()) << "\n" ;
>                errorsOccured = true;
>           }
>           catch (...)
>           {
>                cerr << "\nUnexpected exception during parsing: '" <<
> av[1] << "'\n";
>                errorsOccured = true;
>           }
>
>           if ( errorsOccured || errReporter->getSawErrors() ){
>                cerr << "Parse unsuccessful!" << endl;
>                delete errReporter;
>                delete parser;
>                XMLPlatformUtils::Terminate();
>                return 1;
>           }
>
>           delete errReporter;
>           delete parser;
>
>           cout << "Parse successful!" << endl;
>
>           sleep(2);
>      } /* for */
>
>      XMLPlatformUtils::Terminate();
>
>      return 0;
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]



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

Reply via email to