CreateJs高CPU和内存

CreateJs高CPU和内存

本文介绍了Ionic + CreateJs高CPU和内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

推荐答案

经过如此多的测试,解决方案是将每个模板页面都处理为离子作为根页面。因此,当我导航到新模板页面时,我总是这样做:

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});

这样可以清除ionic保留的所有缓存,并清除createjs中的每个事件,补间动画和元素太。
这极大地提高了应用程序的速度!

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!

这篇关于Ionic + CreateJs高CPU和内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-02 03:07