CodeIgniter Forums

Full Version: Auto Load Model
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Kiran Dangol[/eluser]
Hi Everybody,

I have a question regarding auto loading models. Will autoload models affect in performance in website?

Thanks in advance.

El Forum

[eluser]Sagar Ratnaparkhi[/eluser]
This instructing CI to auto load your models into memory. It wont much affect on site performance. But usually its good to keep most used models in autoload (which needed in most of controllers),else get loaded specifically.

Btw. You can use CI's profiler to review performance.

El Forum

[eluser]Kiran Dangol[/eluser]
Hi Sagar,

Thanks for answer. Now what about library. Will it too affect in speeding?

El Forum

[eluser]PhilTem[/eluser]
It's not easy to answer, but let's state it like this: If you're running on an old machine and autoload 10 models, 10 libraries, 10 configs, and 10 helpers, it will slow down the webserver thus taking longer to create the page plus you will have less memory available for further requests on your server at the same time.
However, if you're running on a rather new machine with some 2GB of RAM it might not be that horrible to autoload many models, libs, ....
Though anyway it is better to load models on a load-when-needed paradigm. Makes your code run faster plus it's just more intuitive, that you load stuff only when you need it thus keeping resources available for other tasks Wink

El Forum

[eluser]Kiran Dangol[/eluser]
Many many thanks to PhilTem. I got clear vision now.
Thank you a lot.