Subject: | Memory Leak in XML::Easy::Content->new() |
Hey Zefram,
XML::Easy::Content->new() is leaking memory
#!/usr/bin/perl
use strict;
use warnings;
use XML::Easy::Content;
use XML::Easy::Element;
use IO::File;
sub vmem_size() {
my $fh = IO::File->new("/proc/self/status", "r") or return undef;
local $/ = "\n";
while(defined(my $line = $fh->getline)) {
return $1 if $line =~ /\AVmSize:[ \t]*([0-9]+)[ \t]*kB[ \t]*\n\z/;
}
return undef;
}
my $size = vmem_size;
for my $count (1..5000) {
# LEAKY CODE!
XML::Easy::Content->new(["",XML::Easy::Element->new("exml",{},[""]),""]);
my $new_size = vmem_size;
if ($new_size != $size) {
$size = $new_size;
print $size, "\n";
}
}
prints
4620
4612
4744
4740
4872
4868
5000
4996
5128
5124
5256
5252
5384
5380
5512
5504
5636
5632
5628
5760
5756
5888
5884
6016
6012
6144
6140
6272
6268
6400
6392
6524
6520
6652
6648
6780
6772
I'm using the XS version (according to /Babel/scripts/modules-check.t)
ok 85 - XML::Easy::xml10_read_document implemented in XS
ok 86 - XML::Easy::Element::new implemented in XS