Chris Cheung <[EMAIL PROTECTED]> writes:
> I need to use Xerces-Perl to repeatedly
>
> - parse XML to DOM tree
> - manipulate the DOM tree
> - pretty-print the DOM tree
>
> It seems that serious memory leak occurs. I do not hold any reference to
> the Perl Xerces object used in the programme and hence the Perl objects
> should be DESTROYed after use, but memory usage keeps on increasing as
> reported by the OS.
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.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]