Ionic + CreateJs 高 CPU 和内存

Ionic + CreateJs high CPU and Memory

我有一个严重的问题,在带有 createjs 库的离子应用程序中,CPU 和 RAM 使用量增加。该问题导致应用程序在一段时间后崩溃。 当我在每个页面都有一个新 canvas 的页面之间导航时,我看到 RAM 和 CPU 急剧增加。 没有内存泄漏。我已经使用 chrome 开发者工具对其进行了测试。

经过如此多的测试,解决方案是将 ionic 中的每个模板页面都视为根页面。所以当我导航到一个新的模板页面时,我总是这样做:

          $ionicHistory.nextViewOptions({
            historyRoot: true,
            disableBack: true
          });

          $ionicHistory.clearCache();
          createjs.Tween.removeAllTweens();
          $scope.stage.removeAllEventListeners();
          $scope.stage.removeAllChildren();
          $state.go("lesson", {}, {reload: true});

这样,ionic 保留的所有缓存都被清除了,createjs 中的每个事件、补间动画和元素也被清除了。 这显着提高了应用程序的速度!