Subject: | _scrubpkg still leaks memory |
Date: | Wed, 11 Oct 2006 18:08:20 +0300 |
To: | bug-Text-Template [...] rt.cpan.org |
From: | Radu Greab <radu [...] yx.ro> |
In Text::Template 0.44 _scrubpkg is still causing memory leaks in long
running processes. The generated package is not cleared and the package
is not removed from the symbol table of Text::Template.
The change below has fixed this problem for me.
diff -Naur Text-Template-1.44.orig/lib/Text/Template.pm Text-Template-1.44/lib/Text/Template.pm
--- Text-Template-1.44.orig/lib/Text/Template.pm 2003-04-29 23:24:30.000000000 +0300
+++ Text-Template-1.44/lib/Text/Template.pm 2006-07-01 05:03:54.000000000 +0300
@@ -428,6 +428,8 @@
foreach my $key (keys %$hash) {
undef $hash->{$key};
}
+ %$hash = ();
+ delete $Text::Template::{$s."::"};
}
}
diff -Naur Text-Template-1.44.orig/t/01-basic.t Text-Template-1.44/t/01-basic.t
--- Text-Template-1.44.orig/t/01-basic.t 2003-04-29 23:13:10.000000000 +0300
+++ Text-Template-1.44/t/01-basic.t 2006-07-01 05:04:24.000000000 +0300
@@ -245,7 +245,9 @@
# (31) Test _scrubpkg for leakiness
$Text::Template::GEN0::test = 1;
Text::Template::_scrubpkg('Text::Template::GEN0');
-if ($Text::Template::GEN0::test) {
+if ($Text::Template::GEN0::test
+ || exists $Text::Template::GEN0::{test}
+ || exists $Text::Template::{'GEN0::'}) {
print "not ok $n\n";
} else {
print "ok $n\n";