[英]getImageData memory leak issue in window's chrome browser : javascript
i am getting memory leak issue on getImageData()[api provided by javascript] when using in a loop for fething the data from canvas in Window 7's chrome browser, it increase chrome memory on each travel on getImageData() api, so after some time when default chrome memory full its being crased.if any one know any workarround of this please suggest. 在Window 7的chrome浏览器中从画布中处理数据时,我在getImageData()[由javascript提供的api]上遇到内存泄漏问题,因此每次使用getImageData()api时,都会增加每次访问时的chrome内存。当默认的chrome内存已满时,如果没有任何了解,请提出建议。
used code: 使用的代码:
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);
this
belongs toowner
of the method on which it is called.this
属于调用它的方法的owner
。
In setTimeout
, this
belongs to window as setTimeout
is method of window
=> window.setTimeout
在
setTimeout
, this
属于window,因为setTimeout
是window
=> window.setTimeout
方法。
Use
.bind()
使用
.bind()
Try this: 尝试这个:
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(paint.bind(this), 500);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.