[Bioperl-l] Memory leak in Bio::Root::Root?

Mike Muratet muratem at eng.uah.edu
Wed Dec 14 12:15:17 EST 2005



Jason

>
> polyn returns a scalar object (blessed) or just some scalar data?
> If you are really calling QStat->polyn( $obj) then 'new' is never called in 
> the first place for the Qstat package.
>

polyn returns a reference to some scalar data. My understanding is that 
'new' would not be called, but then I'm at a loss to explain where all the 
extra memory goes.

> Destructors are automatic, but you can create your own to see when/if the 
> destructor is called.
> sub DESTROY {
> my $self =shift;
> warn("I am calling destroy in the Qstat object\n");
> $self->SUPER::DESTROY;
> }

I will try this.

> You can also inherit from Bio::Root::RootI and call bless on your own if you 
> want to play with whether this is Bio::Root::Root induced behavior.  I'm not 
> sure I understand enough of how it works to tell you where else to look.
>

I will try this, too.

> Is a new $seq_obj getting created every iteration of the loop?  Are these 
> getting cleaned up or is Qstat keeping references  to them, and they are 
> sticking around?  Devel::Cycle doesn't show any memory cycles?
>

A new $seq_obj gets created in every loop of the method that calls QStats 
with the $seq_obj as an argument, but I undef it at the bottom of the 
loop. Should this not be enough to get perl to recycle the memory? I 
haven't tried Devel::Cycle but I will include it to see what it says.

I saw on some of the perl lists a reference to a memory leak in perl 5.8 
with the s/// operator. Have you heard about such a problem?

Thanks for the help

Mike

> On Dec 13, 2005, at 11:32 AM, Mike Muratet wrote:
>
>> Greetings all
>> 
>> I have a problem that surpasses what I know and what I've been able to 
>> glean from perltoot,perboot,etc. Maybe it's a question for a perl list, 
>> but here goes...
>> 
>> I was given a package that calculates some statistics regarding base 
>> repeats in a sequence. It inherits from Bio::Root::Root presumbably to 
>> obtain the exception behavior bestowed by the class judging from the 
>> perldocs and to enforce that the argument is a PrimarySeq object. It has
>> two methods which get called thus:
>> 
>> my $polyn = QStat->polyn($seq_obj);
>> my $nstat = QStat->nmer_stat($seq_obj);
>> 
>> where the returned values are scalar references. The problem is that 
>> script quickly uses up all of the 4GB address space (processing lots of 
>> oligos) and crashes.
>> 
>> I have used Devel::Size to determine the size of these variables and get 
>> 3.8K and 7K. I have tried to undef them at the end of the loop but it has 
>> no effect. I commented out the calls and the problem goes away so the 
>> problem is associated with the QStat object.
>> 
>> The QStat class has a constructor that calls the base constructor:
>>     my $self = $class->SUPER::new(@args);
>> would this demand a destructor somewhere?
>> 
>> Does calling a method out of a class like this invoke all the class 
>> machinery without creating the object with new?
>> 
>> Can someone with experience deriving from Bio::Root::Root offer some 
>> suggestions on how to get the memory back?
>> 
>> Thanks
>> 
>> Mike
>> _______________________________________________
>> Bioperl-l mailing list
>> Bioperl-l at portal.open-bio.org
>> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>
> --
> Jason Stajich
> Duke University
> http://www.duke.edu/~jes12
>
>
>


More information about the Bioperl-l mailing list