[Templates] [PATCH] lazily load File::Temp

darren chamberlain dlc@users.sourceforge.net
Fri, 1 Nov 2002 13:20:32 -0500


* Mark Fowler <mark@twoshortplanks.com> [2002-11-01 13:12]:
> On Fri, 1 Nov 2002, Andy Wardley wrote:
> > Mark Fowler wrote:
> > > Hmm, looks like we could do with a bit of work on automagically
> > > preloading the right things at the right time, if it's possbile.  
> > 
> >   Template::Config->preload() if $ENV{ MOD_PERL };
> 
> Isn't this true even if we've already forked?  Doing this after we've
> forked is quite bad...you'll eat vast chunks of memory (depending on
> how many child processes you have running.)

Yes, but if you use Template in the parent process, then this is a
no-op for the children.

preload() calls Template::Config->load(), which calls require for each
module, and require checks %INC for modules before trying to load them.
Modules will only be loaded once.

(darren)

-- 
Buying books would be a good thing if one could also buy the time to
read them in: but as a rule the purchase of books is mistaken for the
appropriation of their contents.
    -- Arthur Schopenhauer