对象池与schedule 一起使用有内存泄露

  • Creator 版本:2.2.2

  • 目标平台:网页

 this.scheduleOnce(() => {
             this.node.runAction(
                cc.fadeOut(1.0),
                cc.callFunc(()=>{
                    this.nodePool.put(this.node);
                    //this.context.setPool(this.node);
                })
            )
        }, 3);

这样回收对象,对象池不会增加

你们没遇到?

写法有问题,runAction只执行了fadeOut,回调没有执行,加个cc.sequence

3赞

你这样写不会报错吗? 难道用笔记本写的:sweat_smile:

还是多从自己的代码里面找原因吧!
cc.callFunc(()=>{
this.nodePool.put(this.node);
//this.context.setPool(this.node);
})

这个this是你想要的那个this么?

这样写还真不会报错,我以前也写错过,当时就觉得JS真神奇这都不报错:joy:

真机下 bugly是可以捕捉的

箭头函数啊

this.node.runAction(cc.sequence(
            cc.dealyTime(3),
            cc.fadeOut(1.0),
            cc.callFunc(() => {
                this.nodePool.put(this.node);
                //this.context.setPool(this.node);
            })
        ))

你应该这么写

1赞

是不会报错 真特么神奇

不会报错。。。。