cocos-x3.12,捕鱼Demo,疑似内存泄漏,求解决方案,附测试用例

使用cocos-x3.12版本,js语言开发捕鱼类游戏。
xcode检测显示内存泄漏,内存不断缓慢增长直至运行卡顿。
以下为单独取出鱼的测试用例代码,一样有内存泄漏现象,求问题原因。

FishMode.rar (358.2 KB)

var FishWorld = cc.Layer.extend({
ctor:function () {
this._super();
this.init();
return true;
},
init:function(){
var size = cc.winSize;
var bg = new cc.Sprite(res.BG);
bg.setPosition(size.width/2,size.height/2);
bg.setScaleX(size.width/bg.width);
bg.setScaleY(size.height/bg.height);
this.addChild(bg);
var fishLayer = new FishLayer();
this.addChild(fishLayer);
this.schedule(this.doGC,2);
},
doGC:function(){
cc.sys.garbageCollect();
}
});
var Fish = cc.Sprite.extend({
valid:false,
ctor:function(num){
this._super();
this.setTexture(res.FISH);
var numLabel = new cc.LabelTTF(num.toString(),"",30);
numLabel.setPosition(30,15);
this.addChild(numLabel,10);
this.setVisible(false);
return true;
},
reuse:function(){
this.setVisible(true);
this.valid = true;
var size = cc.winSize;
var moveAction = cc.sequence(
cc.place(0,150 + Math.random() * (size.height - 200)),
cc.moveBy(5,cc.p(350 + Math.random() * (size.width - 400),0)),
cc.callFunc(this.removeSelf.bind(this)));
this.runAction(moveAction);
},
removeSelf: function () {
this.valid = false;
this.setVisible(false);
}
});
var FishLayer = cc.Layer.extend({
fishContainer: null,
detectionArray: [],
ctor:function () {
this._super();
this.fishContainer = new cc.Layer();
this.addChild(this.fishContainer);
for (var i = 0; i < 128; ++i) {
var fish = new Fish(i);
this.fishContainer.addChild(fish);
this.detectionArray.push(fish);
}
this.schedule(this.createFish,0.2);
return true;
},
createFish:function(){
var selChild = null;
for (var j = 0; j < this.detectionArray.length; j++) {
selChild = this.detectionArray[j];
if (selChild.valid == false) {
selChild.reuse();
cc.log("创建鱼的序号: " + j);
return;
}
}
}
});
var HelloWorldScene = cc.Scene.extend({
onEnter:function () {
this._super();
var layer = new FishWorld();
this.addChild(layer);
}
});

自问自答了:使用cocos3.15版本引擎新建工程,跑这个测试用例,对比发现,没有内存泄漏的问题了。那么问题来了,怎么把原来的3.12版本引擎升级到3.15,手动直接换掉frameworksm目录下的cocos2d-x全部文件就行了么?

http://forum.cocos.com/t/cocos2dx/51472?u=375281809

帮忙看看s