Skip Menu |

This queue is for tickets about the DateTime-Format-Builder CPAN distribution.

Report information
The Basics
Id: 29034
Status: resolved
Priority: 0/
Queue: DateTime-Format-Builder

People
Owner: Nobody in particular
Requestors: cpan [...] fireartist.com
Cc: autarch [...] urth.org
AdminCc:

Bug Information
Severity: Important
Broken in: 0.7807
Fixed in: 0.79



CC: autarch [...] urth.org
Subject: circular reference causing memory leak
I encountered a memory leak while running a web app under a persistant process. Using Devel::Cycle, I traced it to DateTime/Format/Builder/Parser.pm Attached is a patch which uses Scalar::Util::weaken() to solve the problem. To verify the problem, run the attached "test.pl" - there are 2 circular references reported - both disappear after applying the patch.
Subject: test.pl
use strict; use warnings; use DateTime::Format::Builder; use Devel::Cycle; my $b = DateTime::Format::Builder->new; $b->parser({ strptime => "%d-%m-%Y" }); find_cycle( $b );
Subject: Parser.pm.patch
4a5 > use Scalar::Util qw( weaken ); 62c63,72 < sub set_maker { $_[0]->{maker} = $_[1]; $_[0] } --- > > sub set_maker { > my ($self, $maker) = @_; > > $self->{maker} = $maker; > > weaken( $self->{maker} ); > > return $self; > } 438a449,451 > > weaken( $options ); >