Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/426.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 相位器3:“;活动WebGL上下文太多。最早的上下文将丢失。”;警告和内存泄漏_Javascript_Phaser Framework - Fatal编程技术网

Javascript 相位器3:“;活动WebGL上下文太多。最早的上下文将丢失。”;警告和内存泄漏

Javascript 相位器3:“;活动WebGL上下文太多。最早的上下文将丢失。”;警告和内存泄漏,javascript,phaser-framework,Javascript,Phaser Framework,我正在通过使用interval:setInterval(this.createCharts,1000)创建和销毁许多实例来测试phaser是否存在内存泄漏 游戏配置: const PHASER_CONFIG: GameConfig = { type: Phaser.WEBGL, width: 1200, height: 400, parent: "chart-app", backgroundColor: "#232327" }; 用于创建/销毁实

我正在通过使用interval:
setInterval(this.createCharts,1000)创建和销毁许多实例来测试phaser是否存在内存泄漏

游戏配置:

  const PHASER_CONFIG: GameConfig = {
    type: Phaser.WEBGL,
    width: 1200,
    height: 400,
    parent: "chart-app",
    backgroundColor: "#232327"
  };
用于创建/销毁实例的方法本身:

  // createCharts: if charts are already initialized - destroy all, otherwise - create (allChart is holding active instances)
public createCharts() {
  if (this.allCharts.length > 0) {
    let i = this.allCharts.length;

    while (i--) {
      this.allCharts[i].destroy(true);
      this.allCharts[i] = null;
      this.allCharts.splice(i, 1);
    }
  } else {
    for (let i = 0; i < 10; i++) {
      let chart = new Phaser.Game(PHASER_CONFIG);
      this.allCharts.push(chart);
    }
  }
}
//createCharts:如果图表已初始化-全部销毁,否则-创建(allChart保存活动实例)
公共图表(){
如果(this.allCharts.length>0){
设i=this.allCharts.length;
而(我--){
this.allCharts[i].destroy(true);
this.allCharts[i]=null;
本.所有图表.拼接(i,1);
}
}否则{
for(设i=0;i<10;i++){
让图表=新的Phaser.Game(Phaser_配置);
这个.allCharts.push(图表);
}
}
}
应用程序内存占用正在稳步增长,我看到每个新Phaser.Game的控制台警告——“警告:活动WebGL上下文太多。最早的上下文将丢失。”

不确定我的代码是否有错误,或者我没有正确地销毁phaser实例