[Rt-commit] rt branch, 4.2/potential-leak, created. rt-4.1.23-1-g4a3737b
Ruslan Zakirov
ruz at bestpractical.com
Wed Sep 11 08:13:18 EDT 2013
The branch, 4.2/potential-leak has been created
at 4a3737bfb5d938fb10cbef4f288681b3ab51bd89 (commit)
- Log -----------------------------------------------------------------
commit 4a3737bfb5d938fb10cbef4f288681b3ab51bd89
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Sep 11 16:10:14 2013 +0400
git rid of circular reference in global structure
an anon sub closes over structure where it's stored,
this is circular reference that prevents on time garbage
collection.
it's not a leak right away as strucutre is global and
never changed by core, but any plugin that changes it
may result in a steady leak, so take counter measures.
diff --git a/share/html/Elements/ColumnMap b/share/html/Elements/ColumnMap
index e8ede1d..1a6d18b 100644
--- a/share/html/Elements/ColumnMap
+++ b/share/html/Elements/ColumnMap
@@ -52,9 +52,11 @@ $Attr => undef
</%ARGS>
<%ONCE>
+use Scalar::Util;
+
# This is scary and should totally be refactored -- jesse
-my $COLUMN_MAP;
-$COLUMN_MAP = {
+my ($COLUMN_MAP, $WCOLUMN_MAP);
+$WCOLUMN_MAP = $COLUMN_MAP = {
id => {
attribute => 'id',
title => '#', # loc
@@ -97,7 +99,7 @@ $COLUMN_MAP = {
attribute => sub { return shift @_ },
title => sub { return pop @_ },
value => sub {
- my $self = $COLUMN_MAP->{CustomField};
+ my $self = $WCOLUMN_MAP->{CustomField};
my $cf = $self->{load}->(@_);
return unless $cf->Id;
return $self->{render}->( $cf, $cf->ValuesForObject($_[0])->ItemsArrayRef );
@@ -203,6 +205,8 @@ $COLUMN_MAP = {
$COLUMN_MAP->{'CF'} = $COLUMN_MAP->{'CustomField'};
+Scalar::Util::weaken($WCOLUMN_MAP);
+
my $ROLE_MAP = {};
</%ONCE>
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list