I am using an IBM binary drop. I want to use this parser in a production environment
but I can't if the program size will keep
growing at that rate. I think if if gets way big the OS will kill that process.
What I am trying now is placing the XMLPlatformUtils::Initialize(); and
XMLPlatformUtils::Terminate(); inside the loop to release all
resources on each loop, but I am now getting a core dump on the second loop. I have
to keep looking.
int
main( int ac, char* av[] )
{
if ( ac != 2 ){
cerr << "usage: " << av[0] << " xml file" << endl;
return 1;
}
for ( ;; ){
try
{
XMLPlatformUtils::Initialize();
}
catch( const XMLException& e )
{
cerr << "Error during initialization! :\n"
<< e.getMessage() << "\n";
return 1;
}
DOMParser *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;
XMLPlatformUtils::Terminate();
sleep(1);
} /* for */
return 0;
}
Anthony Zawacki wrote:
> How is your xerces compiled?
>
> I noticed in my own testing that when I compiled the project with -g, the
> memory stabilized. When compiled with -O, it appeared as if there was a
> memory leak. I just chalked it up to some type of compiler bug in the
> optimizer, and we use xerces compiled with -g...
>
> Anthony
>
> |---------+---------------------------->
> | | "Jason Jesso" |
> | | <jjesso@global-ma|
> | | trix.com> |
> | | |
> | | 02/14/2002 09:29 |
> | | AM |
> | | Please respond to|
> | | xerces-c-dev |
> | | |
> |---------+---------------------------->
>
>>------------------------------------------------------------------------------------------------------------------------------|
> |
> |
> | To: [EMAIL PROTECTED]
> |
> | cc:
> |
> | Subject: Re: xerces memory managment
> |
> |
> |
> |
> |
>
>>------------------------------------------------------------------------------------------------------------------------------|
>
> Looks like the formatting is mixed up. This is ther SZ column from ps:
>
> 628
> 636
> 644
> 652
> 660
> 664
> 672
> 676
> 684
> 692
> 696
> 696
> 704
> 708
> 712
> 716
> 720
> 724
> 724
> 732
> 732
> 736
> 740
> 744
> 748
> 752
> 752
> 756
> 760
> 764
> 768
> 772
> 772
> 776
> 780
> 784
> 788
>
> Jason Jesso wrote:
>
> > Let me try here once more to see if anybody can help.
> >
> > I have a program that in an infinite loop creates a parser, parses an
> > xml file and deletes the parser, and so on. The swap space for this
> > simple program keeps increasing (look at the SZ column from ps -ael
> > below) which suggests that the resources used are not getting released.
> > If the memory was getting freed properly the SZ should stabilize. At
> > the beginning of the loop I create a DOMParser and parse an xml file.
> > At the end I "delete" the parser. I cannot see why the resources are
> > not getting released and reused. I am using AIX4.3.3.
> >
> > "SZ"
> > 200001 A 5490 66820 129302 6 63 20 371da 628 320a3718
> > pts/59 0:00 a.out
> > 200001 A 5490 66820 129302 6 63 20 371da 636 320a3718
> > pts/59 0:00 a.out
> > 200001 A 5490 66820 129302 11 65 20 371da 644 320a3718
> > pts/59 0:00 a.out
> > 200001 A 5490 66820 129302 5 62 20 371da 652 320a3718
> > pts/59 0:00 a.out
> > 200001 A 5490 66820 129302 12 66 20 371da 660 320a3718
> > pts/59 0:00 a.out
> > 200001 A 5490 66820 129302 6 63 20 371da 664 320a3718
> > pts/59 0:00 a.out
> > 200001 A 5490 66820 129302 12 66 20 371da 672 320a3718
> > pts/59 0:01 a.out
> > 200001 A 5490 66820 129302 6 63 20 371da 676 320a3718
> > pts/59 0:01 a.out
> > 200001 A 5490 66820 129302 6 63 20 371da 684 320a3718
> > pts/59 0:01 a.out
> > 200001 A 5490 66820 129302 11 65 20 371da 692 320a3718
> > pts/59 0:01 a.out
> > 200001 A 5490 66820 129302 12 66 20 371da 696 320a3718
> > pts/59 0:01 a.out
> > 200001 A 5490 66820 129302 10 65 20 371da 696
> > pts/59 0:01 a.out
> > 200001 A 5490 66820 129302 6 63 20 371da 704 320a3718
> > pts/59 0:01 a.out
> > 200001 A 5490 66820 129302 6 63 20 371da 708 320a3718
> > pts/59 0:02 a.out
> > 200001 A 5490 66820 129302 6 63 20 371da 712 320a3718
> > pts/59 0:02 a.out
> > 200001 A 5490 66820 129302 10 65 20 371da 716 320a3718
> > pts/59 0:02 a.out
> > 200001 A 5490 66820 129302 6 63 20 371da 720 320a3718
> > pts/59 0:02 a.out
> > 200001 A 5490 66820 129302 12 66 20 371da 724 320a3718
> > pts/59 0:02 a.out
> > 200001 A 5490 66820 129302 6 63 20 371da 724 320a3718
> > pts/59 0:02 a.out
> > 200001 A 5490 66820 129302 12 66 20 371da 732 320a3718
> > pts/59 0:02 a.out
> > 200001 A 5490 66820 129302 6 63 20 371da 732 320a3718
> > pts/59 0:03 a.out
> > 200001 A 5490 66820 129302 7 63 20 371da 736 320a3718
> > pts/59 0:03 a.out
> > 200001 A 5490 66820 129302 11 65 20 371da 740 320a3718
> > pts/59 0:03 a.out
> > 200001 A 5490 66820 129302 12 66 20 371da 744 320a3718
> > pts/59 0:03 a.out
> > 200001 A 5490 66820 129302 9 64 20 371da 748
> > pts/59 0:03 a.out
> > 200001 A 5490 66820 129302 12 66 20 371da 752 320a3718
> > pts/59 0:03 a.out
> > 200001 A 5490 66820 129302 6 63 20 371da 752 320a3718
> > pts/59 0:03 a.out
> > 200001 A 5490 66820 129302 6 63 20 371da 756 320a3718
> > pts/59 0:04 a.out
> > 200001 A 5490 66820 129302 8 64 20 371da 760 320a3718
> > pts/59 0:04 a.out
> > 200001 A 5490 66820 129302 5 62 20 371da 764 320a3718
> > pts/59 0:04 a.out
> > 200001 A 5490 66820 129302 12 66 20 371da 768 320a3718
> > pts/59 0:04 a.out
> > 200001 A 5490 66820 129302 6 63 20 371da 772 320a3718
> > pts/59 0:04 a.out
> > 200001 A 5490 66820 129302 12 66 20 371da 772 320a3718
> > pts/59 0:04 a.out
> > 200001 A 5490 66820 129302 6 63 20 371da 776 320a3718
> > pts/59 0:04 a.out
> > 200001 A 5490 66820 129302 6 63 20 371da 780 31638298
> > pts/59 0:04 a.out
> > 200001 A 5490 66820 129302 11 65 20 371da 784 31638298
> > pts/59 0:05 a.out
> > 200001 A 5490 66820 129302 11 65 20 371da 788 31638298
> > pts/59 0:05 a.out
> >
> > 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(1);
> > } /* 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]
>
> ---------------------------------------------------------------------
> 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]