Commit 4fb569e1 authored by Andreas Kusalananda Kähäri's avatar Andreas Kusalananda Kähäri
Browse files

Make the reference from the Translation to its Transcript weak using

Scalar::Util::weaken() to avoid memory leak.
parent ed2c1c89
...@@ -52,6 +52,8 @@ package Bio::EnsEMBL::Translation; ...@@ -52,6 +52,8 @@ package Bio::EnsEMBL::Translation;
use vars qw($AUTOLOAD @ISA); use vars qw($AUTOLOAD @ISA);
use strict; use strict;
use Scalar::Util qw(weaken);
use Bio::EnsEMBL::Utils::Exception qw( deprecate throw warning ); use Bio::EnsEMBL::Utils::Exception qw( deprecate throw warning );
use Bio::EnsEMBL::Utils::Argument qw( rearrange ); use Bio::EnsEMBL::Utils::Argument qw( rearrange );
...@@ -144,6 +146,8 @@ sub transcript { ...@@ -144,6 +146,8 @@ sub transcript {
$self->{'transcript'} = $transcript; $self->{'transcript'} = $transcript;
weaken($self->{'transcript'});
} elsif ( !defined( $self->{'transcript'} ) ) { } elsif ( !defined( $self->{'transcript'} ) ) {
my $adaptor = $self->{'adaptor'}; my $adaptor = $self->{'adaptor'};
if ( !defined($adaptor) ) { if ( !defined($adaptor) ) {
...@@ -158,6 +162,8 @@ sub transcript { ...@@ -158,6 +162,8 @@ sub transcript {
$self->{'transcript'} = $self->{'transcript'} =
$adaptor->db()->get_TranscriptAdaptor() $adaptor->db()->get_TranscriptAdaptor()
->fetch_by_translation_id($dbID); ->fetch_by_translation_id($dbID);
weaken($self->{'transcript'});
} }
return $self->{'transcript'}; return $self->{'transcript'};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment