Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2022-05-28 21:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (101 votes). Check out past polls.

    Notices?