if (enable_pressure_upgrade && !is_critical) { // We are swapping too much. if (mem_pressure < upgrade_pressure) { ALOGI("Event upgraded to critical."); is_critical = true; } }
// If the pressure is larger than downgrade_pressure lmk will not // kill any process, since enough memory is available. if (mem_pressure > downgrade_pressure) { if (debug_process_killing) { ALOGI("Ignore %s memory pressure", is_critical ? "critical" : "medium"); } return; } elseif (is_critical && mem_pressure > upgrade_pressure) { if (debug_process_killing) { ALOGI("Downgrade critical memory pressure"); } // Downgrade event to medium, since enough memory available. is_critical = false; }
if (find_and_kill_process(is_critical) == 0) { if (debug_process_killing) { ALOGI("Nothing to kill"); } } }
memory.usage_in_bytes # show current res_counter usage for memory (See 5.5 for details) memory.memsw.usage_in_bytes # show current res_counter usage for memory+Swap (See 5.5 for details)
如果当前swapping too much并且状态不是critical,就上升压力级别到critical,具体代码就是:
if (enable_pressure_upgrade && !is_critical) { // We are swapping too much. if (mem_pressure < upgrade_pressure) { ALOGI("Event upgraded to critical."); is_critical = true; } }
// If the pressure is larger than downgrade_pressure lmk will not // kill any process, since enough memory is available. if (mem_pressure > downgrade_pressure) { if (debug_process_killing) { ALOGI("Ignore %s memory pressure", is_critical ? "critical" : "medium"); } return; }