Subject: | Memory Leak |
XML::LibXML::SAX leaks memory. I've added a test file which simply
starts the libxml2 sax parser and when parsing very large xml-file (e.g.
ftp://ftp.ncbi.nih.gov/pub/HomoloGene/current/homologene.xml.gz) you may
see how it eats up memory.
1) I've 'NULLed' all callback pointers of xmlSAXHandlerPtr in the
PSaxGethandler function, and the memory leak goes away. So it
doesn't seem to have anything to do with the libxml2 parser.
2) When reactivating just the PSaxCharacters callback it reappears.
3) When calling
count = perl_call_method( "characters", G_SCALAR | G_EVAL );
with the G_DISCARD flag the leak also vanishes, but as far as I
understand the perlcall man page everthing regarding the perlstack
(SAVETMPS, ENTRE, LEAVE etc.) seems to be fine. So it might even be
a perl bug.
This is with verbatim perl 5.8.8 for fedora core 5 tested on i386 and
x86_64. Also testef with the 1.59 cvs-version
Subject: | 31sax.t |
use strict;
package TestHandler;
use base qw(Exporter);
sub new() {
my $t = shift;
my $h = {'COUNT'=>0};
return bless $h,$t;
}
sub start_element() {
my $self = shift;
my $e = shift;
($self->{'COUNT'} % 100000) || print STDERR "START:'".$e->{'Name'}."\r";
$self->{'COUNT'}++;
}
sub end_document() {
my $self = shift;
my $e = shift;
print STDERR "\n ** END DOC ** \n";
}
package main;
use Test;
BEGIN { plan tests => 3 }
use XML::LibXML::SAX;
ok(1);
my $p=new XML::LibXML::SAX(Handler => new TestHandler());
ok(1);
$p->parse_file('t/test-sax.xml') || die " FAILED\n";
ok(1);