cc.Animation 内存泄露求助


buildAnimation: function () {
    this._animation = new cc.Animation();
    var frame;
    var i = 1;
    while (true) {
        frame = cc.spriteFrameCache.getSpriteFrame(this._prefix + "_" + i + ".png");
        if (!frame)
            break;
        this._animation.addSpriteFrame(frame);
        i++;
    }
    this._animation.setDelayPerUnit(this._delayPerUnit);
    this._animation.retain();
},

play: function () {
    this._isPlayOK = false;
    var action = cc.animate(this._animation);
    if ((this._cb && this._cbtarget) || this._repeat >0) {
        action = cc.sequence(action, cc.callFunc(this.finish, this));
    }
    if (this._repeat) {
        action = action.repeat(this._repeat);
    } else {
        action = action.repeatForever();
    }
    this.runAction(action);
},
_clearAnim:function(){
    if (this._animation != null) {
        this._animation.release();
        delete this._animation;
    }
    if(this._plist!=""){
        cc.spriteFrameCache.removeSpriteFramesFromFile(this._plist);
    }
},

使用 new cc.Animation 造成内存持续飙升,然后iOS上崩溃,求大佬指导。
cocos2d-js 3.16
我的图集是固定数量的,就十几个。

最新进展:一旦调用cc.sys.garbageCollect 方法后内存不再迅速增加,怎么解释?cocos大佬帮我看看哈。

==================================
但是cocos2d:Animate 一直是在增加的,数量越来越多,cc.sys.garbageCollect也清不掉

while(true) 这个循环不是一直在执行,没有条件去终止他??

不会,如果死循环会卡死,而不是内存飙升。

new了多少个

一直播不同的动作会一直new

怎么查看这么详细的内存情况?

同样再写捕鱼。。坐等引擎大佬解决。

xcode可以查看的

但是 gc会造成卡顿。

这个问题解决了。解决方法是,不用cc.Animate cc.action 自己重写一套代码播放序列帧动画。

我也是这么想的。正打算自己用js写一套。

cocos是个坑。

有思路提供嗎?

思路就是
先设置动画的时候,先cc.spriteFrameCache.addSpriteFrames(plist)
update里根据时间来setSpriteFrame()