简体   繁体   中英

AngularJs memory

I have an Angular application that loads in only the needed controller / factory or service when it needs to. However i started wondering if all of these scripts eats up the memory the longer my client uses my application.

Take for instance the following example:

Client1 logs into my application here the following controllers are loaded:

LoginController
UserController

Together with these some factories and services are loaded in to store the user for furture reference.

As my Client1 goes through my system the application keeps on adding scripts but never dumping the ones it does not use.

At the last page of my application all of my controllers , factories and services has been loaded and stored in the memory however only a few is actually being used and only a few will be used again.

Should i be concerned about this once my application grows or is that just the normal procedure of AngularJs ?

It sounds to me like this will be the least of your concerns if your application grows. When it comes to overhead and optimization, there's a lot of issues that will be significantly more memory consuming than loaded javascript files.

For instance, too many bindings in your view, listeners you haven't removed on a $scope $destroy event, caching of API calls. I think you shouldn't really worry about this, your application would have to be way too big for this to be an issue, and when this happens, you'll be able to simply optimize the many other areas that are more worrying.

Here you have a few tips to optimize your angular app before you even take this into account.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM