Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by Hero Zzyzzx (Curate)
on Nov 21, 2003 at 17:19 UTC ( #308963=perlquestion: print w/replies, xml ) Need Help??

Hero Zzyzzx has asked for the wisdom of the Perl Monks concerning the following question:

What the question says: If you have a mod_perl application that uses globals that get initialized/reinitialized on each invocation and shared among packages via our(), does this contribute to apache child size growth over time? I could'a SWORE I read something to this effect somewhere. . .

I know ways to manage child size growth, (my favorite being Apache::SizeLimit) so that isn't the issue.

Thanks folks!

-Any sufficiently advanced technology is
indistinguishable from doubletalk.

  • Comment on Does using globals via our() in mod_perl scripts lead to apache child size growth?

Replies are listed 'Best First'.
Re: Does using globals via our() in mod_perl scripts lead to apache child size growth?
by perrin (Chancellor) on Nov 21, 2003 at 18:47 UTC
    Globals will use up as much space as the largest thing you ever put in them. So will lexicals. Be careful about putting something really big (e.g. slurping a file) into any variable in a persistent Perl environment, because the memory will not be returned.
      I thought it does get returned eventually, nowadays? Might only happen when at midnight during high tide, but I seem to remember hearing the never-gets-released rule is no longer true.

      Makeshifts last the longest.

        Memory that is actually freed (which you can do by setting a variable to undef) gets returned to Perl for other uses and in some cases on some systems gets returned to the OS. If you don't explicitly undef, it stay allocated to the variable that used it.
Re: Does using globals via our() in mod_perl scripts lead to apache child size growth?
by CountZero (Bishop) on Nov 21, 2003 at 17:34 UTC
    Anything you do, including nothing can probably lead to Apache child size growth! ;)

    But seriously, I do not think the use of our as such will lead to extra size growth.

    Of course as the mod_perl modules are persistent they will not decrease in size over time. Every change to a variable causes a copy-on-write effect so the shared memory among the children decreases and the private memory space grows for all children.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Re: Does using globals via our() in mod_perl scripts lead to apache child size growth?
by duff (Parson) on Nov 21, 2003 at 17:48 UTC

    That would be strange as "our" is just a scoping mechanism and doesn't allocate anything. How are your vars "shared among packages via our()"? Are they all in the same file? I think our() is a red herring in this case. Perhaps Apache leaks because of whatever you're doing with the package globals, but that has nothing to do with our.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://308963]
Approved by Itatsumaki
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2021-05-15 22:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (150 votes). Check out past polls.

    Notices?