Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: How to deal with the fact that Perl is not releasing memory

by sundialsvc4 (Abbot)
on Jul 07, 2013 at 15:18 UTC ( [id://1042984]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to deal with the fact that Perl is not releasing memory
in thread How to deal with the fact that Perl is not releasing memory

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^4: How to deal with the fact that Perl is not releasing memory
by BrowserUk (Patriarch) on Jul 07, 2013 at 15:38 UTC
    It is genuinely my understanding that declaring the variable within one (in-lined) sub, but using it in another, is Not A Good Thing.™

    Each of the anonymous subs has its own my @messages = (); statement. They are not related!(*) They do not name the same memory space (though they may well re-use some or all of the same memory at different times).

    By moving the declarations outside of the subroutines, you would make them occupy the same memory and never be cleaned or re-initialised and thus they would grow unchecked and totally exacerbate the very problem your "advice" was intended to help with. (Presumably; you do not seem deliberately malicious; just <you pick the adjective>.)

    (*)Each time any of the subs gets called, they get a new instance of that array, which is then discarded -- its memory space given back to the process memory pool for reuse -- when the call to the subroutine ends. The fact that they are used for similar purposes in each the 3 subroutines, and therefore are given similar names, does not mean that they have anything whatsoever in common.

    (In fact, the initialisation is completely redundant, a clean, empty array is created each time the subroutines are called.)

    This is how lexical (my) variables work. The fact that you don't know this beggars belief. The fact that you don't know this but still feel qualified to offer others advice, beggars disbelief!


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re^4: How to deal with the fact that Perl is not releasing memory
by carlbolduc (Novice) on Jul 07, 2013 at 17:45 UTC
    The code wasn't edited when you wrote that comment, but I just did. The complete code is now available.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-03-19 04:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found