Why does it improve ng-repeat performance?

Let's suppose a function called refreshList aiming to call a REST API to retrieve a JSON array containing items.

$scope.refreshList = function () {
  // assuming getting the response object from REST API (Json) here
  $scope.items = response.data.listItems;  
}

And a basic ng-repeat on the HTML side:

<div ng-repeat="item in items track by item.id">

Then, I added a onPullToRefresh function, triggered by this directive, aiming to trigger a refresh of the whole list.

$scope.onPullToRefresh = function () {
  $scope.items = []; 
  $scope.refreshList();
} 

It's HTML is:

<ion-refresher on-refresh="onPullToRefresh()">
</ion-refresher>

The issue is that some pull-to-refresh (while scrolling to the top) can crash the app randomly...

Thus, I decided to alter the $scope.onPullToRefresh function like this:

$scope.onPullToRefresh = function () {
  //$scope.items = [];  commenting this line, causing the potential memory leak and the crash of the app
  $scope.refreshList();  
}

With this update, the app never crashes any more on my iOS device :)

However, I don't figure out what is the main difference by keeping the line emptying the array.
Does it impact directly the ng-repeat directive, causing some mess since the REST API's promise would reassign the content immediatly?
Indeed, Xcode IDE (since cordova app) indicated this error before applying this fix: EXC_BAD_ACCESS.

What might be the reason of this behavior?

I'm pointing out that Ionic (the framework I'm using) is fully tested with Angular 1.2.17 currently, so I'm using this version.

This probably isn't the greatest answer as I'm not 100% certain, but I would suggest it has something to do with the digest.

The ng-repeat likes to work with the one array and not be cleaned out between refreshes. It's designed more to allow you to dynamically add/remove items from the array and the view is updated accordingly in the digest loop. You can do some nice animations for items being added and taken away etc with this.

So when the digest arrives, you've scrapped the array it was watching and thrown a new array into the memory it had.

Try, instead of clearing the array $scope.items = [];, to .pop() each item in the array while it has length.

it will have very little impact to do it this way. Otherwise, the best "Angular" way for the ng-repeat is to do it by just adding the new items to the array and remove any that are now gone.