[Catalyst-dev] Need help debugging Text::ASCIITable <- Solved!

Andy Grundman andy at hybridized.org
Mon Sep 26 20:34:24 CEST 2005


Perrin Harkins wrote:
> On Mon, 2005-09-26 at 11:41 -0400, Andy Grundman wrote:
> 
>>Actually I still think it's a valid test, and so far the only way I can 
>>detect the memory leak.
> 
> 
> You probably really do have a leak, but I would change the test to use
> $x and not $t in the beginning.  Assigning a new instance to the same
> variable over and over should not increase the size even if you do it
> enough to be pretty sure of triggering Perl to fetch more memory.  This
> stuff is really slippery though.  How do we know if GTop counts the size
> of $final or not?  Eek.
> 
> Maybe one of the Devel-Leak* modules would be helpful too?
> 
> 
>>If you comment out the tie in new(), the test will pass.
> 
> 
> That makes sense.  In fact that tie() and the TIEARRAY method itself
> both look like Really Bad Ideas to me.  I'd suggest either significantly
> changing how the tie() stuff is implemented, or making it optional and
> documenting the leak.
> 
> There are some tips for handling circular references safely in this
> article by Matt Sergeant:
> http://perl.com/pub/a/2002/08/07/proxyobject.html

Thanks for the tips!

mst came up with a really simple solution to the problem though:

Instead of tying to a ref in $self, just do this:

sub addrow_overload {
   my $self = shift;
   my @arr;
   tie @arr, $self;
   return \@arr;
}

I sent this to the author and I expect we'll see a 0.17 version within a 
day or so.

-Andy



More information about the Catalyst-dev mailing list