On Fri, Jun 3, 2011 at 10:39 PM, Carlos <carlosgali...@gmail.com> wrote:

> Hi guys,
>
> Many thanks for all your suggestions.
>
> Can you please confirm / correct the following? ...
>
> Does web2py load the code from all models into memory for each and every
> web request?, or does it cache/reuse the same code (as long as it does not
> change)?.
>


  if your model file resides in /models everyone in there will be loaded for
each request, so you can put some model in subfolders related to controllers
and functions and that models will only be loaded for the related functions.


>
> I know web2py executes all models for every web request, but does it
> actually *load* the code into memory as well for every single web request?.
>

Yes, every request is a separate process, every definitions will be loades
in to memory (take a look at the subfolders improvement on latest version)


>
> Furthermore, if I move code from models to modules, will web2py still
> *reload* all code into memory for every web request, or will this be
> avoided?.
>

Every module that you import on to yor application flow will be reloaded on
every request, because in every request web2py destroy& recreate the
environment (many frameworks does that)

But, you can choose if you want to put some objects in cache using web2py
cache functionality, or maybe using an external cache system as memcached.


>
> I just confirmed that by defining a very long class (without even
> instantiating it) in the default Welcome model, I can see the memory being
> consumed by the uwsgi processes while loading /welcome/default/index ...
> this does not mean any leaking on the app, right?, then what can I check in
> order to avoid all this memory leaking?.
>

avoid the use of models to define classes, put in models only constants for
configuration, create your system logic under /modules then import it when
you really need. Or go with models subfolders.


>
> Thanks again,
>
>    Carlos
>
>

Reply via email to