Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Unloading a perl module

by Arguile (Hermit)
on Nov 14, 2001 at 15:24 UTC ( #125293=note: print w/replies, xml ) Need Help??

in reply to Unloading a perl module

Better to declare them in httpd.conf or a type script.
# httpd.conf PerlModule Date::Manip # or use Date::Manip ();

This allows them to be cached on server boot and shared between child processes. The () after the module in is very important as it means the module won't polute your global namespace (exports nothing).

This gives you the performance advantage of having the module already compiled and cached, while keeping your memory requirements (per child) down. Make sure to still use the module in your hanlder/script though; while not always nesseccary it gets pretty confusing if you don't.

If you're running Apache::Registry or PerlRun the rules are slightly different. Check the guide for more info.

Replies are listed 'Best First'.
Re: Re: Unloading a perl module
by mce (Curate) on Nov 14, 2001 at 15:34 UTC
    After a quick supersearch, I came up with this node
    Dr. Mark Ceulemans
    Senior Consultant
    IT Masters, Belgium
Re: Re: Unloading a perl module
by ehdonhon (Curate) on Nov 14, 2001 at 17:38 UTC

    I've tested this in the past. I found that even if you don't have a and just let your cgi scripts use the modules, they still get loaded into global namespace to be shared by all the children. I didn't do a lot of testing in this area, so your results may vary. If they do, I'd love to hear more about it.

      The manual states (IIRC) that modules are shared until you modify internal variables, and then they become specific to the process that modified the variable. So as long as you don't keep state in the modules (few do) you will be getting the most efficient treatment.

      I didn't believe in evil until I dated it.

      This is only true if your CGI scripts get loaded during startup, i.e. any modules you load and any modules they load during server startup will be shared via copy-on-write.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://125293]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2018-04-24 03:17 GMT
Find Nodes?
    Voting Booth?