[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Memory problems in OO context



Try the following code.  If it leaks, the leak is in OneCountryGrabber.  

  for (1..100) {
    my $p = OneCountryGrabber->new->parse_file($some_uri);
  }

Or even:

  for (1..100) {
    OneCountryGrabber->new->parse_file($some_uri);
  }


langfml [at] eng [dot] auburn [dot] edu (Matthew Langford) wrote:
>	    
>	    my $p;
>	    $p = OneCountryGrabber->new->parse_file("$uri");

By the way, the above quotes are futile and a waste of processing.  You're
converting a string into a string, and using Perl's interpolation engine to do
it.

>	    if ( defined($p))
>	    {
>	          # try to clear up some memory
>	        $theInfo = \%{$p->{metaData}};
>	        $p->{metaData} = undef;
>	        undef $p->{metaData};
>	          # this is the big memory hog
>	        undef $p;
>	        return $theInfo;
>	    } 

You seem to be not 'using strict', as $theInfo is not lexically scoped.  That's
the first thing to fix - finding memory leaks without strict syntax is going to
waste a lot of your time.


  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  ken@forum.swarthmore.edu                            The Math Forum



# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org