Hi Salvador, ----- Original Message ----- > From: "Salvador de la Puente González" <[email protected]> > To: [email protected] > Sent: Tuesday, October 30, 2012 11:02:24 AM > Subject: [b2g] B2G memory optimizer > > Hello everybody > > As I said in Gaia meeting today, I'm a little bit concerned about B2G > memory optimizer and what kind of applications it can kill > automatically.
It's a kernel level thing, and fundamentally, it can kill *any* process on the system. It's called the Out-Of-Memory (OOM) killer. Some background is here: http://lwn.net/Articles/317814/ > I don't know what is the component name but I know its function is to > close applications automatically when the device is running out of > memory. But I think we should prioritize applications distinguishing > between those that are essential for the proper operation of the > device. > Note, AFAIK, as soon as an application is OOP, it is eligible to be > killed when no more memory is available. Despite usage criteria, > applications such as homescreen, dialer (think about emergency > calls), > keyboard (consider its big dictionary) or first run experience should > be > auto-closed only if there is **no other way** to free memory. > > So I propose **to indicate the priority in the application > manifest**. > Of course, a non certified application should not be privileged... Or > may this decision should be taken by the user via Settings? > > I propose four levels of prioritization: > > NOTE: > - Names don't say anything about prioritization but about the > application's importance instead. > - Priorities between brackets were available only for certified > applications. > > * [critical]: without these applications, the device is useless -> > prevent optimizer to close the application at all. I.e: system, > homescreen, first running experience and dialer > * [desirable]: applications that complete the device experience > but > are not essential for the device to be useful -> schedule the > application to be closed in last term. I.e: keyboard, cost control... > * favourite: applications that the user would like to kept alive > -> > these applications should be kept open but if there are no default > (see > below) applications, then these will be closed. I.e: sms, facebook... > * default: normal behaviour -> these applications will be closed > in > first term. I.e: calculator, maps... > > What do you think about this? So the only real control we have on all of this is something called oom_adj (a -17 to +15 score adjustment, or oom_score_adj (a -1000 to +1000 that maps directlry onto oom_adj). If you grab https://github.com/mozilla-b2g/gonk-misc/pull/49 you can use "b2g-ps --oom" on the phone to examine the oom_score and oom_score_adj fields of all of the b2g processes. Currently, b2g itself has a oom_score_adj of 0, foreground gets 67, and background gets 400. These get added to a memory usage score, which is computed largely as RSS / total available memory. When an app moves to the background/foreground, the oom_score_adj is adjusted dynamically. You can see the RSS in ps or b2g-ps (reported in Kb) and the total amount of memory comes from /proc/meminfo MemTotal entry. The RSS is inflated by the amount of PTE's used (this relates to the MMU, but it's fairly low % wise). When the kernel runs out of memory, it goes around and tries to free stuff up by freeing cached memory and other things. When all of that is exhausted, if computes the oom_score for all of the processes in the system and kills the one with the highest score. Dave Hylands _______________________________________________ dev-b2g mailing list [email protected] https://lists.mozilla.org/listinfo/dev-b2g
