Skip to content

Commit

Permalink
Add a workaround for a memory leak involving Perl's handling of @isa.
Browse files Browse the repository at this point in the history
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
jtbraun committed Feb 21, 2012
1 parent 589ac9b commit 682b23b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/Parse/RecDescent.pm
Expand Up @@ -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.'::'};
}
}
Expand Down

0 comments on commit 682b23b

Please sign in to comment.