问题
I have a serious problem with an increasing CPU and RAM usage in an ionic app with createjs library. The problem cause the app to crash after a while. As I am navigating between pages where each page has a new canvas, I see the RAM and CPU to dramatically increase. There is no memory leak. I have tested it with chrome developer tools.
回答1:
After so so much testing, the solution was to treat each template page in ionic as a root page. So when I was navigating to a new template page I always did:
$ionicHistory.nextViewOptions({
historyRoot: true,
disableBack: true
});
$ionicHistory.clearCache();
createjs.Tween.removeAllTweens();
$scope.stage.removeAllEventListeners();
$scope.stage.removeAllChildren();
$state.go("lesson", {}, {reload: true});
This way all cache that ionic kept was cleared and every event, tween motion and element in createjs was cleared too. This increased the speed of the app drammatically!
来源:https://stackoverflow.com/questions/37236976/ionic-createjs-high-cpu-and-memory