From 4fb569e1ad690756305953660377d1993ed82422 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kusalananda=20K=C3=A4h=C3=A4ri?= <ak4@sanger.ac.uk> Date: Thu, 1 Jul 2010 15:40:56 +0000 Subject: [PATCH] Make the reference from the Translation to its Transcript weak using Scalar::Util::weaken() to avoid memory leak. --- modules/Bio/EnsEMBL/Translation.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/Bio/EnsEMBL/Translation.pm b/modules/Bio/EnsEMBL/Translation.pm index ab2ef34de0..148409f9a0 100755 --- a/modules/Bio/EnsEMBL/Translation.pm +++ b/modules/Bio/EnsEMBL/Translation.pm @@ -52,6 +52,8 @@ package Bio::EnsEMBL::Translation; use vars qw($AUTOLOAD @ISA); use strict; +use Scalar::Util qw(weaken); + use Bio::EnsEMBL::Utils::Exception qw( deprecate throw warning ); use Bio::EnsEMBL::Utils::Argument qw( rearrange ); @@ -144,6 +146,8 @@ sub transcript { $self->{'transcript'} = $transcript; + weaken($self->{'transcript'}); + } elsif ( !defined( $self->{'transcript'} ) ) { my $adaptor = $self->{'adaptor'}; if ( !defined($adaptor) ) { @@ -158,6 +162,8 @@ sub transcript { $self->{'transcript'} = $adaptor->db()->get_TranscriptAdaptor() ->fetch_by_translation_id($dbID); + + weaken($self->{'transcript'}); } return $self->{'transcript'}; -- GitLab