perl process is killed while loading large xsd schema in memory
Paulo SantAnna <[email protected]> Wed, 29 Jun 2011 11:52:15 -0700
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I have this requirement of loading somewhat large XSD files ( >32M) and use
them to
validate corresponding XML instance files. I have used * what I think * is a
typical LibXML
approach but it runs out of memory on a Linux (Ubuntu 10.10) with 1G RAM. It
runs fine in another much more powerful CentOS box with 8G RAM and I could
consider trying to find the exact memory requirements, however since I will
run multiple of these tests I'm just afraid I'm postponing the inevitable.
Currently just the following is enough to run out of memory:
------------------------
#!/usr/bin/perl
use strict;
use warnings;
use XML::LibXML;
my $xsdfile = 'config.xsd';
my $schema = eval { XML::LibXML::Schema->new( location => $xsdfile ) };
if ( $@ ) {
warn "$@\n";
exit;
}
print "All good\n";
-----------------------------------
After that I run (below is not an exact code snippet):
my $parser = XML::LibXML->new( recover => 1 );
$doc = eval { $parser->parse_file($xmlfile) };
eval { $schema->validate($doc) };
To validate the XML doc. I ran across an example using
XML::Validator::Schema<http://search.cpan.org/~samtregar/XML-Validator-Schema-1.08/Schema.pm>
and
a SAX parser but it seems to be a somewhat deprecated library. Any
suggestions? If possible I would like to keep using XML::LibXML as I don't
control the environments where this code needs to run.
Thanks,
Paulo
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs