On Tue, Sep 23, 2008 at 4:09 PM, Michael Peters <[EMAIL PROTECTED]>wrote:

> Joshua Miller wrote:
>
>  Using autoloader to only require in the subclasses when needed will also
>> keep memory usage down, as rarely used modules won't get loaded unless
>> they're actually called.
>>
>
> Are you running under normal CGI (do people still do that?).
>
> If not, and you're running on a "good" OS (one with copy-on-write memory)
> and you're using a forking environment (mod_perl, or most FastCGI
> implementations) you should pre-load all of you modules up front. This will
> actually decrease memory usage. Or course if you have a really, really
> rarely used module that is really, really big you might reconsider this
> advice. Unless I'm missing something?
>

You're not missing anything. I'm running under mod_perl under linux boxen,
and do pre-load a ton of modules that are used often. It's a > million line
system though, so there's a whole lot that doesn't load frequently. The
pre-load all module is a good rule of thumb - it's a lot easier than
defining how many uses a day justifies pre-loading.

The above snippet can be updated to just do a "use" on all the module at the
top, and remove the require part... but that will also mean that it'll need
updated every time you add a new subclass. The above will automatically find
and use the new subclass, which makes it good generic code (IMHO). And you
can always put the pre-loads in a separate apache startup file anyway.

--
Josh I.

#####  CGI::Application community mailing list  ################
##                                                            ##
##  To unsubscribe, or change your message delivery options,  ##
##  visit:  http://www.erlbaum.net/mailman/listinfo/cgiapp    ##
##                                                            ##
##  Web archive:   http://www.erlbaum.net/pipermail/cgiapp/   ##
##  Wiki:          http://cgiapp.erlbaum.net/                 ##
##                                                            ##
################################################################

Reply via email to