窗口中的getImageData内存泄漏问题';s chrome浏览器:javascript

窗口中的getImageData内存泄漏问题';s chrome浏览器:javascript,javascript,google-chrome,google-chrome-app,Javascript,Google Chrome,Google Chrome App,我在getImageData()[api由javascript提供]上遇到内存泄漏问题,当在Window 7的chrome浏览器中使用循环从画布中提取数据时,它会在getImageData()api上的每次行程中增加chrome内存,因此,当默认chrome内存满一段时间后,它就会崩溃。如果有人知道这方面的任何工作,请提出建议 使用的代码: this.surface.drawImage(this.st1, 0, 0, this.canvas.width, this.canvas.height);

我在getImageData()[api由javascript提供]上遇到内存泄漏问题,当在Window 7的chrome浏览器中使用循环从画布中提取数据时,它会在getImageData()api上的每次行程中增加chrome内存,因此,当默认chrome内存满一段时间后,它就会崩溃。如果有人知道这方面的任何工作,请提出建议

使用的代码:

this.surface.drawImage(this.st1, 0, 0, this.canvas.width, this.canvas.height); 
var data = this.surface.getImageData(0,0, this.canvas.width, 
this.canvas.height);
this.timer = setTimeout(this.paint, 500);
属于调用它的方法的所有者

setTimeout
中,此
属于窗口,因为
setTimeout
window
=>
窗口的方法。setTimeout

使用
.bind()

试试这个:

this.surface.drawImage(this.st1,0,0,this.canvas.width,this.canvas.height);
var data=this.surface.getImageData(0,0,this.canvas.width,
这是一个很好的例子;
this.timer=setTimeout(paint.bind(this),500)
属于调用它的方法的所有者

setTimeout
中,此
属于窗口,因为
setTimeout
window
=>
窗口的方法。setTimeout

使用
.bind()

试试这个:

this.surface.drawImage(this.st1,0,0,this.canvas.width,this.canvas.height);
var data=this.surface.getImageData(0,0,this.canvas.width,
这是一个很好的例子;

this.timer=setTimeout(paint.bind(this),500)已尝试(.bind())您的解决方案,但仍在不断增加chrome内存:不工作,请建议我是否缺少任何东西。以及为什么创建var\u this=this;但是你没有使用它。你能分享你正在画布上绘制的图像文件的尺寸吗?画布:宽度:1024高度:786,maxFrameRate:25请参考此示例并单击顶部按钮执行:因此仅供参考的问题仅在Windows 7 chrome BrowserTested(.bind())上发布然而,你的解决方案仍然在不断增加chrome内存:不工作,请建议我是否缺少任何东西。还有,为什么你要创建var\u this=this;但你没有使用它。你能分享你正在画布上绘制的图像文件的尺寸吗?画布:宽度:1024高度:786,maxFrameRate:25请参考此示例并单击顶部按钮执行:因此仅供参考的问题仅在window 7 chrome浏览器上