3

I'm repeatedly passing image data from an HTML5 canvas to a Web Worker using a Transferrable Object --

Condensed Code:

var worker = new Worker("test.js");
setInterval(function () {
    var data = context.getImageData(0, 0, canvas.width, canvas.height);

    worker.webkitPostMessage(data, [data]);
}, 100);

The problem is that memory usage increases astronomically every few seconds and doesn't appear to decrease when the function isn't being called. For cases in which the memory usage exceeds a certain threshold, chrome will actually crash as a result of this leak. I would welcome any and all suggestions, including alternative methods for sending data to the Web Worker. Many thanks!

James Evans
  • 830
  • 8
  • 12

1 Answers1

0

Well, I guess it is not about web workers.

var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');

setInterval(function () {
  var data = context.getImageData(0, 0, canvas.width, canvas.height);
}, 100);

This code I think provides the same memory leak. Also I've found this issues:

  1. http://code.google.com/p/chromium/issues/detail?id=51171
  2. JavaScript memory problem with canvas
Community
  • 1
  • 1
Danil Speransky
  • 29,891
  • 5
  • 68
  • 79