Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^6: "goto" memory leak

by jethro (Monsignor)
on Mar 31, 2016 at 13:03 UTC ( #1159199=note: print w/replies, xml ) Need Help??

in reply to Re^5: "goto" memory leak
in thread "goto" memory leak

Thanks, much clearer now what is happening.

Still my argument stands, a bazillion code snippets to free the same single memory location is (at least from the perspective of the script writer) a memory leak. The questions is only if it is advisable to fix it since the fix would probably incur a heavy runtime cost.

It will only affect long running polling code in a few specific cases (for example microcontroller scripts to measure environmental stuff could fall into the trap). It is avoidable but the program writer would need to know information about an implementation detail of "my" that is not in the man pages at the moment.

Replies are listed 'Best First'.
Re^7: "goto" memory leak
by Anonymous Monk on Mar 31, 2016 at 14:36 UTC

    If it's any easier, think of my as malloc(). Inside a while loop, the my variable goes out of scope each iteration, so the storage may be reclaimed. To get the same effect with a goto loop, you'll need explicit block scoping:

    again: { my $h; } goto again;

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2021-03-02 04:58 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (36 votes). Check out past polls.