[cgiapp] How to lazy-load runmodes
gvim
gvimrc at gmail.com
Tue May 24 07:26:16 EDT 2011
On 24/05/2011 05:27, Ron Savage wrote:
> Hi gvim
>
> You don't have to use or load them all. If you adopt
> CGI::Application::Dispatch and a MVC structure, only 1 controller
> module gets loaded, and hence only the run modes in that module get
> loaded.
>
But if I have only 1 controller module which 'use's 10 or 15 runmode modules:
use base 'AppBase';
use Register;
use Email;
use Another
........
sub setup {
my $c = shift;
$c->start_mode('register');
$c->run_modes({
register => 'Register::register',
email => 'Email::email',
another => 'Another::runmode',
...................
});
}
1;
... then I'm loading all 15 at startup, right? Even worse if I pack all those 15 into subs without external modules as in a lot of examples on the CA website.
> There are plenty of modules on CPAN which use this method.
>
> Mine include App::Office::Contacts, App::Office::CMS,
> Business::Cart::Generic and CGI::Application::Demo::Dispatch (hint).
>
> Of course, if you run them under plack or Starman, they are
> permanently resident anyway, so the startup overhead is only incurred
> once.
But the memory footprint is still affected, surely? I'm just trying to weigh the benefits when running CGI::Application on a VM with a modest amount of memory.
>
> All the above modules include a plack/starman runner httpd/*/*.psgi
> using C::A::D.
>
More information about the cgiapp
mailing list