I have a problem in my main application, where using the app without refreshing, the memory (and CPU usage) is getting higher.
I managed to reproduce it: https://jsfiddle.net/fmgy778r/
angular.module('TestModule', []).controller('TestController', function ($controller, $scope) {
$scope.a = [];
for (var i = 0; i < 10 * 1000 * 1000; i++)
$scope.a.push("stringstring" + i);
});
Press shift + ESC on Chrome.
Now press "problem", and your memory for that tab will be 1GB+-.
Press "default" and see that the memory is still 1GB.
Press "problem" and see that the memory is going down and then up again.
Press "default" once, and then press "problem" 10 times in a fast click spamy way, and see your memory spiking to 1.5-2GB
I have about 30 modules in my system, and if such thing is happening to all, I see why the memory is just bloating.
Why is this happening?
How can it be fixed?
*I know I should use this and not $scope, but I wanted to reproduce the real code.