Permalink
Browse files

Add a workaround for a memory leak involving Perl's handling of @ISA.

Perl has a bug that creates a circular reference between @ISA and that
variable's stash:

  https://rt.perl.org/rt3/Ticket/Display.html?id=92708

Emptying the array before deleting the stash seems to prevent the
leak.
  • Loading branch information...
1 parent 589ac9b commit 682b23b4f76542172ee534ea9ba83d4e40468053 @jtbraun committed Feb 21, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/Parse/RecDescent.pm
View
@@ -1950,6 +1950,17 @@ sub DESTROY {
my $namespace = $self->{namespace};
$namespace =~ s/Parse::RecDescent:://;
if (!$self->{_precompiled}) {
+ # BEGIN WORKAROUND
+ # Perl has a bug that creates a circular reference between
+ # @ISA and that variable's stash:
+ # https://rt.perl.org/rt3/Ticket/Display.html?id=92708
+ # Emptying the array before deleting the stash seems to
+ # prevent the leak. Once the ticket above has been resolved,
+ # these two lines can be removed.
+ no strict 'refs';
+ @{$self->{namespace} . '::ISA'} = ();
+ # END WORKAROUND
+
delete $Parse::RecDescent::{$namespace.'::'};
}
}

0 comments on commit 682b23b

Please sign in to comment.