I have an odd memory leak in my ion and cord application. There is no leak in chrome, but when I launch the application, it definitely is. Essentially, I need to scroll through a large dataset and set it to $scope .
Data in real life is collected from the server, but here I just simulated it using a function. In addition, in a real application, $scope.vote is called by clicking a button, not a button that enters a for loop.
However, this is a good simulation for him. The data is smaller, but I made the loop more active so you can see the leak. Leakage is much more important when using large datasets that I collect from the server.
I am currently running v1.0.0-beta.13 (beta 14 causes many other problems for me ...) The kit contains angular 1.2.25.
I dropped this until the test case below:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> <title></title> <link href="css/ionic.app.css" rel="stylesheet"> <script src="lib/ionic/js/ionic.bundle.js"></script> <script src="cordova.js"></script> <script> angular.module('starter', ['ionic']) .controller("testCtrl", function($scope){ $scope.b = []; $scope.count = 0; function getBallots() { $scope.b.push({ _id: "54d7d680bdd622982e91a45f" }); $scope.b.push({ _id: "54d7ef2ac659dd302a128924" }); $scope.b.push({ _id: "54d7ef2ac659dd302a128929" }); } getBallots(); $scope.vote = function(){ if($scope.b.length){ $scope.ballot = $scope.b.shift(); $scope.count ++; } if($scope.b.length<=0){ getBallots() } }; $scope.start = function(){ for(var i = 0; i < 10000; i++){ $scope.vote() } } }) </script> </head> <body ng-app="starter" ng-controller="testCtrl"> {{ballot._id}}<br> {{count}} <br><br><br> <button class="button button-large button-royal" ng-click="start()">BUTTON</button> </body> </html>
The Tools tool shows when it analyzes the application on my iphone 5S. I know that the leak size here is quite small in this case, but in my real application the data is much larger and this becomes a big problem. Each of the strokes is the result of 5 consecutive clicks on the button.

The tool trace file can be downloaded at: http://s000.tinyupload.com/?file_id=52410311803253693651
angularjs ios memory-leaks cordova ionic-framework
wlingke
source share