From 35f72be50b8a2d11bce591dcdac5dc3fa336dac0 Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Mon, 16 Sep 2013 10:57:39 -0700 Subject: Implement issue #10691359: Kill long-running processes We now have the activity manager kill long-running processes during idle maintanence. This involved adding some more information to the activity manager about the current memory state, so that it could know if it really should bother killing anything. While doing this, I also improved how we determine when memory is getting low by better ignoring cases where processes are going away for other reasons (such as now idle maintenance). We now won't raise our memory state if either a process is going away because we wanted it gone for another reason or the total number of processes is not decreasing. The idle maintanence killing also uses new per-process information about whether the process has ever gone into the cached state since the last idle maintenance, and the initial pss and current pss size over its run time. Change-Id: Iceaa7ffb2ad2015c33a64133a72a272b56dbad53 --- cmds/am/src/com/android/commands/am/Am.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'cmds/am') diff --git a/cmds/am/src/com/android/commands/am/Am.java b/cmds/am/src/com/android/commands/am/Am.java index d78572b..c18f542 100644 --- a/cmds/am/src/com/android/commands/am/Am.java +++ b/cmds/am/src/com/android/commands/am/Am.java @@ -100,6 +100,7 @@ public class Am extends BaseCommand { " am monitor [--gdb ]\n" + " am hang [--allow-restart]\n" + " am restart\n" + + " am idle-maintenance\n" + " am screen-compat [on|off] \n" + " am to-uri [INTENT]\n" + " am to-intent-uri [INTENT]\n" + @@ -189,6 +190,8 @@ public class Am extends BaseCommand { "\n" + "am restart: restart the user-space system.\n" + "\n" + + "am idle-maintenance: perform idle maintenance now.\n" + + "\n" + "am screen-compat: control screen compatibility mode of .\n" + "\n" + "am to-uri: print the given Intent specification as a URI.\n" + @@ -295,6 +298,8 @@ public class Am extends BaseCommand { runHang(); } else if (op.equals("restart")) { runRestart(); + } else if (op.equals("idle-maintenance")) { + runIdleMaintenance(); } else if (op.equals("screen-compat")) { runScreenCompat(); } else if (op.equals("to-uri")) { @@ -1393,6 +1398,20 @@ public class Am extends BaseCommand { mAm.restart(); } + private void runIdleMaintenance() throws Exception { + String opt; + while ((opt=nextOption()) != null) { + System.err.println("Error: Unknown option: " + opt); + return; + } + + System.out.println("Performing idle maintenance..."); + Intent intent = new Intent( + "com.android.server.IdleMaintenanceService.action.FORCE_IDLE_MAINTENANCE"); + mAm.broadcastIntent(null, intent, null, null, 0, null, null, null, + android.app.AppOpsManager.OP_NONE, true, false, UserHandle.USER_ALL); + } + private void runScreenCompat() throws Exception { String mode = nextArgRequired(); boolean enabled; -- cgit v1.1