Hi!
We were able to narrow the scope of the problem a little. Apparently
it's on Template::Stash::XS
-----------8<------------
# this leaks big time
use Template::Stash::XS;
my $stash = Template::Stash::XS->new( { x => {} } );
while (1) {
$s->get( ['x', 0, 'y', 0] );
}
-----------8<------------
Using 'top' or something equivalent, you can easily see it eating up a
Gig of memory in just a few seconds!
If I change the code above replacing Template::Stash::XS with just
Template::Stash, the leak goes away.
Now, I tried following the leak, but I don't have much experience
debugging XS, so here's my top result:
-----------8<------------
use Devel::Leak;
use Template::Stash::XS;
my $stash = Template::Stash::XS->new( { x => {} } );
my $handle;
Devel::Leak::NoteSV($handle);
$stash->get( ['x', 0] );
Devel::Leak::CheckSV($handle);
----------->8------------
This yields no output, meaning nothing leaked. However, if I change the
get() statement to:
$stash->get( ['x', 0, 'y', 0] );
I get the output:
new 0x8a6bc80 :
new 0x8928538 :
Hope this helps! And thanks again for the time and attention to work on
such a helpful piece of code :)
Cheers,
garu
On Wed May 13 20:57:09 2009, GARU wrote:
Show quoted text> If I run this:
>
> --------------8<--------------
> use strict;
> use warnings;
>
> use Template;
>
> my $text = '[% x.y %]';
> my $out;
> my $tt = Template->new();
>
> while (1) {
> $out = undef;
> $tt->process(\$text, { x => {} }, \$out);
> }
> --------------8<--------------
>
> and go to a different terminal to watch the process with 'top' or any
> equivalent tool, I see memory consumption rising abruptly for the process.
>
> If I change the $tt->process() line above to either:
>
> $tt->process(\$text, {}, \$out);
>
> or
>
> $tt->process(\$text, { x => { y => 42 } }, \$out);
>
> , the leak goes away.
>
> Thoughts?
>
> Anyway, ***thank you*** for such an amazing template system :)