Ionic + CreateJs high CPU and Memory

梦想的初衷 提交于 2020-04-14 07:00:49

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!