From b3e5100711d6378ba5bdc09a0355488e79048acf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Thu, 24 Mar 2011 10:25:26 +0100 Subject: [PATCH] Leaks in SL::Template::Plugin::T8 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Filter werden in Template::Toolkit in einer anonymen Closure einfach im Kontext verlinkt. Dadurch geht _jedes_ Filter Objekt verloren und leakt. Diese Änderung cacht das T8 Filterobjekt, da es sowieso statisch ist. Das beschränkt die Leaks auf einmal ~100 Byte. --- SL/Template/Plugin/T8.pm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/SL/Template/Plugin/T8.pm b/SL/Template/Plugin/T8.pm index 6c584d72c..ca62e8604 100644 --- a/SL/Template/Plugin/T8.pm +++ b/SL/Template/Plugin/T8.pm @@ -1,14 +1,19 @@ package SL::Template::Plugin::T8; use strict; +use parent qw( Template::Plugin::Filter ); -use Template::Plugin::Filter; -use base qw( Template::Plugin::Filter ); +my $cached_instance; + +sub new { + my ($class) = shift; + + return $cached_instance ||= $class->SUPER::new(@_); +} sub init { my $self = shift; - # first arg can specify filter name $self->install_filter($self->{ _ARGS }->[0] || 'T8'); return $self; -- 2.20.1