Re: destroy xml object

Thomas Krichel <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
  Michael Ludwig writes

> Thomas Krichel schrieb am 07.07.2010 um 06:40 (+0200):
> >    A script of mine repeatedly calls 
> >  
> >  my $in_xml = eval {
> >    XML::LibXML->load_xml(location=>$in_file);
> >  };
> >  
> >    Memory usage goes through the roof. Eventually, the
> >    script is killed by the kernel. In my despair I try
> >    
> >  $in_xml->DESTOY();
> >  
> >    That bombs out completely. What is a boy to do here?
> 

> The first step would be to provide exact details instead of "through
> the roof" and "bomb out completely". File size, error message? In
> addition, post a *minimal* self-contained program reproducing the case
> so we can run this at home and see you're not doing something
> unthinkably funny in your script. 

  I don't have this yet for the memory leak, but I do have 
  it now for the "bombs out completely" problem. I don't have
  a better term for it, but try

#!/usr/bin/perl

use warnings;
use strict;
use XML::LibXML;

## pick any well-formed XML file
my $xml_file=$ENV{'HOME'}."/foo.xml";
## take a maximum parse count
my $max_parse_count=100000000000;

my $dom=XML::LibXML->new();
my $parse_count=0;

while($parse_count++<$max_parse_count) {
  my $in_xml=eval {
    XML::LibXML->load_xml(location=>$xml_file);
    ###$dom->parse_file($xml_file);
  };
  $in_xml->DESTROY;
}


  Thanks and cheers,

  Thomas Krichel                    http://openlib.org/home/krichel
                                http://authorclaim.org/profile/pkr1
                                               skype: thomaskrichel
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.