title: Angular.js memory leak with ngRepeat on polled data
body: <p>I've got what seems to be a memory leak in my angular.js app.  Basically, the page consists of a table of information that is updated every five seconds from the JSON-encoded result of an AJAX call.  I've created a simplified jsfiddle version here: <a href="http://jsfiddle.net/alalonde/TtGXW/6/" rel="nofollow">http://jsfiddle.net/alalonde/TtGXW/6/</a> </p>
  
  <p>The controller:</p>
  
  <pre><code>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);
  }
  </code></pre>
  
  <p>A snippet of the template:</p>
  
  <pre><code>&lt;table class="table table-striped table-bordered" ng-controller="HostController"&gt;
    &lt;tr&gt;
      &lt;th&gt;Status&lt;/th&gt;
    &lt;th&gt;...
    &lt;/tr&gt;
    &lt;tr ng-repeat="enc in encoders"&gt;
      &lt;td&gt;
        &lt;div&gt;{{ enc.name }}&lt;/div&gt;
        &lt;div ng-show="enc.version"&gt;
          v{{ enc.version.major }}.{{ enc.version.minor }}-{{ enc.version.rev }}
          &lt;span ng-show="enc.version.user"&gt;- {{ enc.version.user }}&lt;/span&gt;
        &lt;/div&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>When taking a heap snapshot in Chrome every minute or so, the memory usage rises slightly each time.  I've applied Igor Minar's fix to my local angular.js (<a href="https://github.com/angular/angular.js/commit/bd524fc4e5fc0feffe85632a7a6560da6bd9b762" rel="nofollow">https://github.com/angular/angular.js/commit/bd524fc4e5fc0feffe85632a7a6560da6bd9b762</a>) which helped a lot, but the memory usage is still inexorably creeping up.  </p>
  
  <p>Any hints on using the Chrome memory profiler with angular.js would be appreciated.</p>