Subject: | Memory leak while processing many files with DOM |
The following program takes an ever growing amount of memory,
while the memory should be freed at each iteration.
#! perl -w
use strict;
use XML::LibXML;
for(my $i=0; $i<1_000_000; $i++){
my $entry = "<entry><sense></sense><sense></sense></entry>";
my $parser = new XML::LibXML;
my $doc = $parser->parse_string($entry);
my $root = $doc->getDocumentElement;
my $g = 0;
# The memory leak comes from the following line
foreach my $sense (@{ $root->getElementsByTagName("sense") }){ $g++ }
}
Perl version: 5.6.1
XML-LibXML version: 1.40
Operating system:
% uname -a
Linux borel5.institut.math.jussieu.fr 2.4.2-2smp #1 SMP Sun Apr 8 20:21:34 EDT 2001 i686 unknown