Hi Jas

  Thanks a lot for your help. I installed XML-Xerces-2.3.0-4 
and run the attached test script modified according to your attached 
code. I used the Linux tool "top" to monitor the memory usage of the 
progress while it is running. However, the memory usage still grow from 
9M to 29M for 500 iteration of parsing. Did I do anything wrong?


On 15 Nov 2003, Jason E. Stewart wrote:

> Hi Chris,
> 
> So I think I've solved this. First use DOMBuilder, and second ensure
> that resetDocumentPool() gets called after you are finished with the
> DOM tree. Here's some code stolen from my memtest.pl:
> 
> my $impl = XML::Xerces::DOMImplementationRegistry::getDOMImplementation('LS');
> my $parser = 
> $impl->createDOMBuilder($XML::Xerces::DOMImplementationLS::MODE_SYNCHRONOUS,'');
> 
> 
> sub validate_builder {
>   my $xml = shift ;
>   my $parser = shift;
> 
>   eval {
>     $parser->setFeature("$XML::Xerces::XMLUni::fgDOMNamespaces", $namespace) ;
>     $parser->setFeature("$XML::Xerces::XMLUni::fgXercesSchema", $schema) ;
>     $parser->setFeature("$XML::Xerces::XMLUni::fgXercesSchemaFullChecking", $schema) 
> ;
> #    $parser->setFeature("http://apache.org/xml/features/validation-error-as-fatal";, 
> $validate) ;
>   };
>   XML::Xerces::error($@) if $@;
> 
> 
>   eval {
>     $parser->setFeature("$XML::Xerces::XMLUni::fgDOMValidation", $validate) ;
> #    $parser->setFeature("$XML::Xerces::XMLUni::fgDOMValidateIfSchema", 0) ;
>   };
>   XML::Xerces::error($@) if $@;
> 
>   eval {
>     # my $is = XML::Xerces::MemBufInputSource->new($xml);
>     # my $is = XML::Xerces::LocalFileInputSource->new($OPTIONS{file});
>     $parser->parseURI($OPTIONS{file}) ;
>   } ;
>   XML::Xerces::error($@) if $@;
>   $parser->resetDocumentPool();
> }
> 
> Using this code I'm not getting any perceptable leaks with 2.3.0-4.
> 
> Let me know if this helps,
> jas.
> 

-- 
Best Regards,

Chris Cheung
Center for Large-Scale Computation

Have a nice day!
#!/usr/bin/perl -w

use XML::Xerces;

for (my $i = 0; $i < 500; $i++)
{
        my $impl = XML::Xerces::DOMImplementationRegistry::getDOMImplementation('LS');

        my $parser =
        
$impl->createDOMBuilder($XML::Xerces::DOMImplementationLS::MODE_SYNCHRONOUS,'');

        $parser->setFeature("$XML::Xerces::XMLUni::fgDOMNamespaces", 1);
        $parser->setFeature("$XML::Xerces::XMLUni::fgXercesSchema", 0);
        $parser->setFeature("$XML::Xerces::XMLUni::fgXercesSchemaFullChecking",
                0) ;

        $parser->setFeature("$XML::Xerces::XMLUni::fgDOMValidation", 0);

        my $doc = $parser->parseURI("example.xml") ;

        # I used adoptDocument since I need to use the DOMDocument after
        # the parser die.
        # Do I need to call some clean-up API afterward?

        $parser->resetDocumentPool();

        print "$i\n";
}

print "Test Ended\n";
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to