Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: Re: Re: what's faster than .=

by TimToady (Parson)
on Mar 11, 2003 at 02:05 UTC ( [id://241912]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: what's faster than .=
in thread what's faster than .=

It's slightly documented in the Camel book on page 598: "Don't undef long strings and arrays if they'll be reused for the same purpose. This helps prevent reallocation when the string or arrayh must be re-extended."

It's reliable till someone changes it... :-)

Perl 5 never GCs a sub's lexicals in the sense we're talking about here. Certainly things can happen to objects that go out of scope, but that's different.

Perl doesn't know when a sub might be called again. It merely assumes it.

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: what's faster than .=
by BrowserUk (Patriarch) on Mar 11, 2003 at 02:44 UTC

    Perl 5 never GCs a sub's lexicals in the sense we're talking about here. Certainly things can happen to objects that go out of scope, but that's different.

    Curiouser and curiouser (as someone famous, literally speaking, once said:).

    Doesn't that imply that the often advised "scope as tightly as possible to reduce memory usage" is (at least some of the time) wrong? Or shouldn't I be asking such questions:)?


    Examine what is said, not who speaks.
    1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
    2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
    3) Any sufficiently advanced technology is indistinguishable from magic.
    Arthur C. Clarke.
      Scoping tightly may reduce the number of separate variables needed, since more will be reused. In general though, if you want to free the memory from a lexical you have to undef it. This has been discussed many times on the mod_perl list and on PerlMonks as well. You can probably find some stuff about it with SuperSearch.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-25 23:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found