cocos creator2.2.0在update函数中使用Map的for…of循环,模拟器运行会报如下错误
Simulator:
Fatal error in , line 0
Fatal process out of memory: Zone
#FailureMessage Object: 0A21CDE0
at HTMLElement.print-simulator-log (D:\CocosCreator_2.2.0\resources\app.asar\editor\builtin\scene\panel\messages\scene.js:1:1608)
at Object.e._dispatch (D:\CocosCreator_2.2.0\resources\app.asar\editor-framework\lib\renderer\panel.js:1:1876)
at EventEmitter. (D:\CocosCreator_2.2.0\resources\app.asar\editor-framework\lib\renderer\ipc.js:1:2952)
at EventEmitter.emit (events.js:194:13)
Simulator: Error initializing symbols (8). Dumping unresolved backtrace:
5001E683
77C33032
500172E2
0FE0D166
10328766
1060CEA9
1058C1F6
at HTMLElement.print-simulator-log (D:\CocosCreator_2.2.0\resources\app.asar\editor\builtin\scene\panel\messages\scene.js:1:1608)
at Object.e._dispatch (D:\CocosCreator_2.2.0\resources\app.asar\editor-framework\lib\renderer\panel.js:1:1876)
at EventEmitter.<anonymous> (D:\CocosCreator_2.2.0\resources\app.asar\editor-framework\lib\renderer\ipc.js:1:2952)
at EventEmitter.emit (events.js:194:13)
代码:
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
// LIFE-CYCLE CALLBACKS:
onLoad () {
this._testMap = new Map();
this._testMap.set(1, 1);
this._testDelta = 0;
},
start () {
},
update (dt) {
this._testDelta += dt;
if (this._testDelta < 60)
{
return;
}
this._testDelta = 0;
for (let [k, v] of this._testMap)
{
cc.log("test k: " + k);
}
},
});
第一次输出正常,第二次输出时报错