[whatwg] Low Memory Event

Ian Hickson ian at hixie.ch
Thu Dec 30 19:01:39 PST 2010


On Fri, 24 Sep 2010, Charles Pritchard wrote:
>
> Do we have a route, or DOM events that signal when the device has a low 
> memory condition?
> 
> My computer is constantly running low in memory. Mozilla-apps 
> (thunderbird) start hiding unneeded icons; Chrome betas just go ahead 
> and crash the active process.
> 
> Mobile platforms all have such low memory hooks for their apps.
> 
> They're necessary to allow designers to add additional logic to handle 
> the condition by releasing buffers, serializing data, using 
> localStorage, etc.

For practical reasons, we can't really constrain user agents in situations 
related to hardware limitations. Different platforms have different ways 
of dealing with these situations and it's not always possible for a user 
agent to comply with specific requirements. (For example, when running out 
of memory, the UA might no longer be able to spin up the JS interpreter.)


On Mon, 27 Sep 2010, Rob Evans wrote:
>
> I think one of the most useful things that a js script could know is how 
> much memory is available and how much the current page is using. I'm 
> writing a js game engine and knowing how much I can safely site in 
> memory would be incredibly useful!
> 
> That way I can do everything to maximize engine performance. I could 
> determine how large I could make a canvas element, how much data I can 
> store client side in arrays or if need be, switch to asking the server 
> for data more often and storing less client side.

Please don't use all my memory for your Web-based game. :-) I may just be 
running it in the background while finding a video to watch, for example, 
in which case I really don't want the game using all my resources. Also, 
resources tend not to be as simple as the above could describe. For 
example, right now you could allocate 3 GB of RAM on this machine without 
any difficulty, you could allocate 6 GB if you're willing to wait for 
other apps to be paged out, and you could allocate 12 GB if you're willing 
to have your RAM be backed by a slower medium (like disk), thrashing like 
crazy. But that's right now; maybe while you're getting the 3 GB of data 
set up, some other app will allocate 20 GB and will evict you entirely out 
of the computer. And maybe when you create a 100-character string in one 
browser it actually takes just 100 bytes, but on another browser it might 
take 1000. So not only would the information be unreliable, it would be 
insufficient to really make good judgements.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


More information about the whatwg mailing list