[whatwg] Low Memory Event

Charles Pritchard chuck at jumis.com
Fri Jan 7 16:16:30 PST 2011


> Date: Sun, 02 Jan 2011 04:59:14 -0600 From: Boris Zbarsky 
> <bzbarsky at MIT.EDU> On 1/1/11 6:53 PM, Charles Pritchard wrote:
>> >  ArrayBuffer and Canvas use contiguous memory segments. You don't need a
>> >  complex GC pass to let those ones go.
> Yes, you do.  You can't let go of the canvas buffer without letting go
> of the canvas rendering contexts and canvas elements referencing it.
> And those used to be referenced from JS, so the only way they can go
> away is via a GC.
>
> Similar for ArrayBuffer: the memory segment is owned by various
> garbage-collected objects, and can't go away until they do.
With canvas, you can just set  canvas.width = 1; to let the memory go, 
without a complex GC.
canvas.width = 1 can be used to quickly release several megs of ram.

On that note, a method of invalidating ArrayBufferView and 
CanvasPixelArray would be helpful in the future.
Maybe that's something we could talk about, as we discuss the 
feasibility of responding to lowmemory events.

Here's a thread considering .close() as an invalidate method name:
http://www.khronos.org/webgl/public-mailing-list/archives/1009/msg00229.html

And here's a quick attempt at example, on my part:

el.onclick = function() {
   imageData.close();
   worker.postMessage(imageData);
// imageData.data[0] = 0; now throws INVALID_STATE_ERR from this thread
}

.close() signals to postMessage to use a pointer, instead of cloning the 
object.














More information about the whatwg mailing list