Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: global variable initialization inside try{}

by targetsmart (Curate)
on Apr 10, 2009 at 06:13 UTC ( #756758=note: print w/ replies, xml ) Need Help??


in reply to Re: global variable initialization inside try{}
in thread global variable initialization inside try{}

I just read this Re: Re2: Learning how to use the Error module by example
where it was told that the below code will leak memory

use Error qw( :try ); sub leaky_function { my $foo = 7; try { # do something here try { $foo++; } catch Error::Simple with { # whatever }; } catch Error::Simple with { # whatever }; }
please explain me how it leaks memory when I call it every time.

Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.


Comment on Re^2: global variable initialization inside try{}
Download Code
Re^3: global variable initialization inside try{}
by perrin (Chancellor) on Apr 10, 2009 at 13:17 UTC
    In the bottom of that post it says that this leak was fixed in recent versions of perl. It used to leak by creating copies of $foo. If you're on a version prior to 5.8, you should still be concerned about it. The other problems with the try{} syntax still exist.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://756758]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2014-12-29 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (190 votes), past polls