My application uses ui-router. I noticed that the memory changes when changing routes. I checked the code for ordinary things like event binding, element destruction, etc., but still I get more than 50% of the initial memory the first time the application loads. I suspect his ui-router, but cannot find any problems going through his code. Everything seems to be cleaned and disposed of properly.
The application starts with an initial memory of 50 MB and goes to the next page and back adds 30 MB for a total of 80 MB, etc. etc. (which on chrome, in firefox it is much worse)
In short, I went through the $ destroy method, and in my tests moving to the next page, $ destroy was executed 100 times.
By adding the following lines of code to $ destroy, it gets 300 times, and the leakage decreases from 50% to 10%.
The change is trivial, and from the CPU load time that I measured, it does not affect performance, even if I have this loop down the $ scope hierarchy:
$destroy: function() {
I'm not sure why, although this is happening, perhaps some experts may shed some light, and if there are potential problems with this change in $ destroy. I am using angular 1.4.7
thanks
Geoch source share