angularjs - Angular.js memory leak with ngRepeat on polled data -
i've got seems memory leak in angular.js app. basically, page consists of table of info updated every 5 seconds json-encoded result of ajax call. i've created simplified jsfiddle version here: http://jsfiddle.net/alalonde/ttgxw/6/
the controller:
function hostcontroller($scope, $timeout, data) { $scope.encoders = data.load(); $scope.refreshinterval = 5; $scope.reload = function () { $scope.encoders = data.load(); }; $timeout(function doreload() { $scope.reload(); $timeout(doreload, $scope.refreshinterval * 1000); }, 5000); }
a snippet of template:
<table class="table table-striped table-bordered" ng-controller="hostcontroller"> <tr> <th>status</th> <th>... </tr> <tr ng-repeat="enc in encoders"> <td> <div>{{ enc.name }}</div> <div ng-show="enc.version"> v{{ enc.version.major }}.{{ enc.version.minor }}-{{ enc.version.rev }} <span ng-show="enc.version.user">- {{ enc.version.user }}</span> </div> </td> </tr> </table>
when taking heap snapshot in chrome every min or so, memory usage rises each time. i've applied igor minar's prepare local angular.js (https://github.com/angular/angular.js/commit/bd524fc4e5fc0feffe85632a7a6560da6bd9b762) helped lot, memory usage still inexorably creeping up.
any hints on using chrome memory profiler angular.js appreciated.
i had same issue memory consumption when polling info , using ng-repeat loop on , render rows.
when used "item in items" got ever increasing memory usage when used "item in items track $index" memory usage stable , gc cleaned properly.
memory-leaks angularjs
No comments:
Post a Comment