[whatwg] Low Memory Event

Glenn Maynard glenn at zewt.org
Sat Jan 1 13:43:38 PST 2011


> I'd like to be able to listen for them on the desktop as well.

You need to know a lot about the host system to know what "low memory"
even means.  Does it mean allocations may start failing soon?  Does it
mean we're deep into swap, causing serious performance issues but not
failed allocations?  Even that's hard to define; you can be using a
lot of swap, but it may be for entirely unused, idle background
applications and not indicate memory pressure at all.

This definitely seems useful on mobile platforms, where memory is much
more limited, memory management is much less complex, and being able
to deal reliably with memory limitations is a much more pressing
issue.  But on desktop platforms, even native applications written for
a specific platform run into trouble when they try to respond
"intelligently" to memory pressure, and the vast majority don't try.

On Sat, Jan 1, 2011 at 3:39 PM, Charles Pritchard <chuck at jumis.com> wrote:
> Here are some example implementations; it's up to the vendor, not the spec.
>
> Tabbed browsing implementation:
> Send a lowmemory event to hidden tabs listening (for lowmemory), that have
> not been visible for more than 60 seconds.
> (This is a partial example, as it doesn't detail when the tabs would be
> checked for visibility. )

An event like this needs to have a consistent meaning to allow
applications to respond meaningfully.  If it has varied meanings--or
if it has attributes to indicate each meaning, but they don't get
implemented in practice, or are too generic and don't accurately
describe the situation on each platform and configuration--then
applications can't respond correctly.

For example, responding to being an idle tab by releasing resources is
the wrong thing to do if there's plenty of memory available.  I have 8
GB of memory and Firefox rarely uses more than 512 MB.  Don't make me
wait for resources to be reloaded (or re-cached, or whatever the
resource is) because they were released "just in case".  I have lots
of memory precisely because I don't want to wait; I want applications
to cache as much as possible.  (The "tab visibility" proposal seems
more appropriate for this particular example, anyway.)

I'm not saying this is impossible, but memory management is
exceptionally complex, varies wildly across platforms, varies wildly
depending on how much memory and swap a system has, and on the
behavior of other applications on the system.  I'd be concerned about
a generic, loosely-defined "lowmemory" event with entirely unrelated
meanings encouraging developers to respond to it in ways that only
happen to make sense on the platform they're testing on.

-- 
Glenn Maynard



More information about the whatwg mailing list