From: Vladimir Timofeev Date: Wed, 10 Jul 2013 20:55:02 +0000 (+0400) Subject: Fix memleak for long-lived resultsets. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1cb73de45598d482af714f2f27ab39cbf6341fcf;p=dbsrgits%2FDBIx-Class-Historic.git Fix memleak for long-lived resultsets. It is a recursive attributes hash chain when call search on the same resultset many times. --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 8ff9868..e5cf5ad 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -2446,6 +2446,10 @@ sub _select_args { # invoked, and that's just bad... ### + # Small hack, remove potential infinity _sql_maker_select_args chain + # when call queries on the same resultset many times + delete $attrs->{_sqlmaker_select_args}; + return ( 'select', @{ $orig_attrs->{_sqlmaker_select_args} = [ $ident, $select, $where, $attrs, @limit_args ]} ); diff --git a/t/110leaktrace.t b/t/110leaktrace.t new file mode 100644 index 0000000..b50a784 --- /dev/null +++ b/t/110leaktrace.t @@ -0,0 +1,20 @@ +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +BEGIN { + eval "use Test::LeakTrace"; + plan 'skip_all' => 'Test::LeakTrace required for this tests' if $@; +} + +my $schema = DBICTest->init_schema(); + +plan tests => 1; + +my $artist_rs = $schema->resultset('Artist')->search({},{order_by=>'me.artistid'}); +no_leaks_ok { + my @artists = $artist_rs->all; +};