I tracked down to this:
use Template::Plugin::Filter;
for (1..100_000) {
warn $_;
my $filter = Template::Plugin::Filter->new;
$filter->factory;
}
which leaks. factory() goes like this:
sub factory {
my $self = shift;
if ($self->{ _DYNAMIC }) {
return $self->{ _DYNAMIC_FILTER } ||= [ sub {
my ($context, @args) = @_;
my $config = ref $args[-1] eq 'HASH' ? pop(@args) : { };
return sub {
$self->filter(shift, \@args, $config);
};
}, 1 ];
}
else {
return $self->{ _STATIC_FILTER } ||= sub {
$self->filter(shift);
};
}
}
$self is holded in subroutine reference. changing it to $class->new
will fix leaks, but it does break something behind the scenes...
At Thu, 10 Oct 2002 17:46:40 +0900,
Tatsuhiko Miyagawa wrote:
>
> Anyone has any clue to solve this?
> We're in trouble with TT filter leaks in mod_perl environment,
>
> Thanks
>
> At Fri, 13 Sep 2002 20:42:56 +0900,
> Tatsuhiko Miyagawa wrote:
> >
> > Using filter plugin (Comma, Number.Format, FillInForm) in big loop
> > seems to leak. I've searched the archive and have found
> >
> > http://template-toolkit.org/pipermail/templates/2001-March/000784.html
> >
> > which says:
> >
> > | One simple solution would be to have the context reset() method clear
> > | the FILTER_CACHE hash, breaking the circle and allowing Perl to clean up.
> > | Possibly the better approach is to improve the filters mechanism in some
> > | way to allow filters to specify that they shouldn't be cached. Prevention
> > | rather than cure.
> > |
> > | If you get a chance and have the inclination, try fixing the
> > | Template::Context reset() method to 'undef $self->{ FILTER_CACHE }'
> > | and see if that helps.
> >
> > How's the current status for this issue?
> > Can I do something in Plugin module code to avoid caching?
--
Tatsuhiko Miyagawa <[EMAIL PROTECTED]>
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://www.template-toolkit.org/mailman/listinfo/templates