[whatwg] Low Memory Event

Roger Hågensen rescator at emsai.net
Sat Jan 1 18:52:54 PST 2011


On 2011-01-02 03:27, Kornel Lesiński wrote:
> On Sun, 02 Jan 2011 00:53:48 -0000, Charles Pritchard 
> <chuck at jumis.com> wrote:
>
>> ArrayBuffer and Canvas use contiguous memory segments. You don't need 
>> a complex GC pass to let those ones go.
>> For my use cases, those are the two types I'm working with.
>>
>> Keeping them around helps the speed of my app, letting them go
>> cuts down on memory usage.
>
> Maybe better solution would be to add "purgeable" flag to canvas (i.e. 
> allow browser to clear canvas at any time) or some way to create/mark 
> weak references? (i.e. a reference to object that can be changed to 
> null if browser is in low-memory situation).
>
> Although, I'm not convinced that handling of low memory in JS is 
> necessary. Browsers already have some ways to free memory, e.g. by 
> freeing all bitmaps for <img> or simply by unloading whole pages.
>
> Amount of available memory, even on mobile devices, increases 
> dramatically each year. It's possible that by the time this feature 
> gets specified, implemented, released and installed on significant 
> number of devices it will be irrelevant. On my desktop computer I 
> often have 100 tabs open and memory is not an issue, and my mobile 
> phone has 1/16th of that RAM already.
>

I think this is starting to get off topic, as we're now into OS memory 
allocation territory.
If the browser is told by the OS or the browser "feels" it need to 
conserve memory it can do whatever it pleases, OS stability trumphs web 
page/app/script/whatever, and should always do so.

Charles, you initially said you where worried about this since you used 
undo buffers.
Why not simply add undo buffers to the Canvas spec? That way the browser 
can start tossing away the oldest undo buffers automatically when it 
starts getting memory anorexic.
And depending on the browser implementation and the OS and hardware 
support, on some systems the Canvas undo buffers could even be in 
graphics memory.
It's wrong for Canvas to have undo stuff in active memory, most graphics 
programs store the undo on disk or it's paged out to a swapfile at the 
least.
So if you have to make your own undo buffers for Canvas, then I'd say 
that Canvas is lacking and might need undo buffers as part of it's spec.


-- 
Roger "Rescator" Hågensen.
Freelancer - http://www.EmSai.net/



More information about the whatwg mailing list