Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re^4: Does using globals via our() in mod_perl scripts lead to apache child size growth?

by perrin (Chancellor)
on Nov 22, 2003 at 22:53 UTC ( [id://309196]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Does using globals via our() in mod_perl scripts lead to apache child size growth?
in thread Does using globals via our() in mod_perl scripts lead to apache child size growth?

No, you have to set it to undef.
  • Comment on Re: Re^4: Does using globals via our() in mod_perl scripts lead to apache child size growth?

Replies are listed 'Best First'.
Re: Re: Re^4: Does using globals via our() in mod_perl scripts lead to apache child size growth?
by agrundma (Novice) on Dec 02, 2003 at 22:16 UTC
    I have to disagree.

    From http://perl.apache.org/docs/1.0/guide/performance.html#toc_Memory_leakage
    --
    Memory leakage

    Scripts under mod_perl can very easily leak memory! Global variables stay around indefinitely, lexically scoped variables (declared with my()) are destroyed when they go out of scope, provided there are no references to them from outside that scope.

    Perl doesn't return the memory it acquired from the kernel. It does reuse it though!
    --

    The last line does imply that you shouldn't do things like slurp a 100MB file into a my() var, because even though it will be freed, that 100MB is only available to Perl and won't go back to the OS. However, it's not as bad as if my() vars were never freed automatically. If that were the case, nearly every mod_perl application out there would eventually use up all available memory (without Apache::SizeLimit coming to the rescue).
      I'm not sure I follow exactly what you're disagreeing with. The bit about lexicals retaining their memory unless explicitly freed has been confirmed many times. Memory that Perl takes does sometimes go back to the OS, but this behavior is very OS-dependent. You can read some comments from elian about this if you look on SuperSearch.

      By the way, not to brag, but I helped write the mod_perl guide that you're quoting from.

Log In?
Username:
Password:

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

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

    No recent polls found