Need help with leaks
am 18.12.2007 22:45:27 von Ancient_Hacker
Okay, I have about 6,000 lines of Perl code, which generally work
GREAT, but I have a big memory leak.
Yes, I had to do some sloppy coding to leak memory in Perl. I have a
LOT of global variables.
After each pass of the program a few hundred megabytes get leaked into
various variables.
I HAVE added a sub to reset everything to '' and (), but I must be
forgetting a few variables, as on each pass the memory usage goes UP
and UP and UP, until it gets to about 1.6GB and everything crashes.
Is there some way to view ALL of the Perl symbol tables and see what
I'm forgetting to trash?
I tried several of the hints on the net, including peeking at keys
\main::, and so on, but all I see there are barewords and some sub
names, none of my variable names.
Any hints appreciated.
Re: Need help with leaks
am 19.12.2007 00:07:51 von krahnj
Abble wrote:
>
> Okay, I have about 6,000 lines of Perl code, which generally work
> GREAT, but I have a big memory leak.
>
> Yes, I had to do some sloppy coding to leak memory in Perl. I have a
> LOT of global variables.
> After each pass of the program a few hundred megabytes get leaked into
> various variables.
> I HAVE added a sub to reset everything to '' and (), but I must be
> forgetting a few variables, as on each pass the memory usage goes UP
> and UP and UP, until it gets to about 1.6GB and everything crashes.
perldoc -f reset
John
--
use Perl;
program
fulfillment
Re: Need help with leaks
am 19.12.2007 11:48:44 von Spiros Denaxas
On Dec 18, 10:03 pm, Joost Diepenmaat wrote:
> Abble writes:
> > Okay, I have about 6,000 lines of Perl code, which generally work
> > GREAT, but I have a big memory leak.
>
> > Yes, I had to do some sloppy coding to leak memory in Perl. I have a
> > LOT of global variables.
> > After each pass of the program a few hundred megabytes get leaked into
> > various variables.
>
> I always think of a memory leak as allocating memory and then losing
> the references to it so you *can't* free it anymore. Forgetting to empty
> out some variable that's still accessible is not a leak. Other people
> may disagree.
>
> > I HAVE added a sub to reset everything to '' and (), but I must be
> > forgetting a few variables, as on each pass the memory usage goes UP
> > and UP and UP, until it gets to about 1.6GB and everything crashes.
>
> AFAIK setting variables to '' and () doesn't necessarily reclaim any
> memory to perl. undef VARIABLE may work better. But it looks like the
> real problem is elsewhere.
You are right, in the vast majority of cases it doesn't.
http://perldoc.perl.org/perlfaq3.html#How-can-I-make-my-Perl -program-take-less-memory%3f
Spiros
>
> You may have some circular structures, which will never get reclaimed
> until the perl interpreter exits.
>
> http://search.cpan.org/~lds/Devel-Cycle-1.07/lib/Devel/Cycle .pm
>
> > Is there some way to view ALL of the Perl symbol tables and see what
> > I'm forgetting to trash?
>
> There's stuff athttp://search.cpan.org/search?query=devel+leak&mode=all
> andhttp://search.cpan.org/search?query=devel&mode=all
>
> This one looks interesting:
>
> http://search.cpan.org/~cgautam/Devel-DumpSizes-0.01/lib/Dev el/DumpSi...
>
> HTH,
> Joost.