Loading services/core/java/com/android/server/am/ActivityManagerService.java +36 −0 Original line number Diff line number Diff line Loading @@ -18328,8 +18328,37 @@ public final class ActivityManagerService extends ActivityManagerNative int nextCachedAdj = curCachedAdj+1; int curEmptyAdj = ProcessList.CACHED_APP_MIN_ADJ; int nextEmptyAdj = curEmptyAdj+2; ProcessRecord selectedAppRecord = null; long serviceLastActivity = 0; int numBServices = 0; for (int i=N-1; i>=0; i--) { ProcessRecord app = mLruProcesses.get(i); if (ProcessList.ENABLE_B_SERVICE_PROPAGATION && app.serviceb) { numBServices++; for (int s=app.services.size()-1; s>=0; s--) { ServiceRecord sr = app.services.valueAt(s); if (DEBUG_OOM_ADJ) { Slog.d(TAG,"app.processName = "+app.processName+ " serviceb = "+ app.serviceb+ " s = "+s+" sr.lastActivity = "+sr.lastActivity+ " packageName = "+sr.packageName+" processName = "+sr.processName); } if (SystemClock.uptimeMillis()-sr.lastActivity < ProcessList.MIN_BSERVICE_AGING_TIME) { if (DEBUG_OOM_ADJ) { Slog.d(TAG,"Not aged enough!!!"); } continue; } if (serviceLastActivity == 0) { serviceLastActivity = sr.lastActivity; selectedAppRecord = app; } else if (sr.lastActivity < serviceLastActivity) { serviceLastActivity = sr.lastActivity; selectedAppRecord = app; } } } if (DEBUG_OOM_ADJ && selectedAppRecord != null) { Slog.d(TAG,"Identified app.processName = "+selectedAppRecord.processName+" app.pid = "+selectedAppRecord.pid); } if (!app.killedByAm && app.thread != null) { app.procStateChanged = false; computeOomAdjLocked(app, ProcessList.UNKNOWN_ADJ, TOP_APP, true, now); Loading Loading @@ -18432,6 +18461,13 @@ public final class ActivityManagerService extends ActivityManagerNative } } } if ((numBServices > ProcessList.BSERVICE_APP_THRESHOLD) && (true == mAllowLowerMemLevel) && (selectedAppRecord!=null)) { ProcessList.setOomAdj(selectedAppRecord.pid, selectedAppRecord.info.uid ,ProcessList.CACHED_APP_MAX_ADJ); selectedAppRecord.setAdj = selectedAppRecord.curAdj; if (DEBUG_OOM_ADJ) { Slog.d(TAG,"app.processName = "+ selectedAppRecord.processName + " app.pid = "+selectedAppRecord.pid + " is moved to higher adj"); } } mNumServiceProcs = mNewNumServiceProcs; services/core/java/com/android/server/am/ProcessList.java +7 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,13 @@ final class ProcessList { // without empty apps being able to push them out of memory. static final int MIN_CACHED_APPS = 2; // Min aging threshold in milliseconds to consider a B services for propagation to higher adj static final int MIN_BSERVICE_AGING_TIME = SystemProperties.getInt("ro.sys.fw.bservice_age",5000); // Threshold for B Services when in memory pressure static final int BSERVICE_APP_THRESHOLD = SystemProperties.getInt("ro.sys.fw.bservice_limit",5); // Enable B service aging propagation on memory pressure. static final boolean ENABLE_B_SERVICE_PROPAGATION = SystemProperties.getBoolean("ro.sys.fw.bservice_enable",false); // The maximum number of cached processes we will keep around before killing them. // NOTE: this constant is *only* a control to not let us go too crazy with // keeping around processes on devices with large amounts of RAM. For devices that Loading Loading
services/core/java/com/android/server/am/ActivityManagerService.java +36 −0 Original line number Diff line number Diff line Loading @@ -18328,8 +18328,37 @@ public final class ActivityManagerService extends ActivityManagerNative int nextCachedAdj = curCachedAdj+1; int curEmptyAdj = ProcessList.CACHED_APP_MIN_ADJ; int nextEmptyAdj = curEmptyAdj+2; ProcessRecord selectedAppRecord = null; long serviceLastActivity = 0; int numBServices = 0; for (int i=N-1; i>=0; i--) { ProcessRecord app = mLruProcesses.get(i); if (ProcessList.ENABLE_B_SERVICE_PROPAGATION && app.serviceb) { numBServices++; for (int s=app.services.size()-1; s>=0; s--) { ServiceRecord sr = app.services.valueAt(s); if (DEBUG_OOM_ADJ) { Slog.d(TAG,"app.processName = "+app.processName+ " serviceb = "+ app.serviceb+ " s = "+s+" sr.lastActivity = "+sr.lastActivity+ " packageName = "+sr.packageName+" processName = "+sr.processName); } if (SystemClock.uptimeMillis()-sr.lastActivity < ProcessList.MIN_BSERVICE_AGING_TIME) { if (DEBUG_OOM_ADJ) { Slog.d(TAG,"Not aged enough!!!"); } continue; } if (serviceLastActivity == 0) { serviceLastActivity = sr.lastActivity; selectedAppRecord = app; } else if (sr.lastActivity < serviceLastActivity) { serviceLastActivity = sr.lastActivity; selectedAppRecord = app; } } } if (DEBUG_OOM_ADJ && selectedAppRecord != null) { Slog.d(TAG,"Identified app.processName = "+selectedAppRecord.processName+" app.pid = "+selectedAppRecord.pid); } if (!app.killedByAm && app.thread != null) { app.procStateChanged = false; computeOomAdjLocked(app, ProcessList.UNKNOWN_ADJ, TOP_APP, true, now); Loading Loading @@ -18432,6 +18461,13 @@ public final class ActivityManagerService extends ActivityManagerNative } } } if ((numBServices > ProcessList.BSERVICE_APP_THRESHOLD) && (true == mAllowLowerMemLevel) && (selectedAppRecord!=null)) { ProcessList.setOomAdj(selectedAppRecord.pid, selectedAppRecord.info.uid ,ProcessList.CACHED_APP_MAX_ADJ); selectedAppRecord.setAdj = selectedAppRecord.curAdj; if (DEBUG_OOM_ADJ) { Slog.d(TAG,"app.processName = "+ selectedAppRecord.processName + " app.pid = "+selectedAppRecord.pid + " is moved to higher adj"); } } mNumServiceProcs = mNewNumServiceProcs;
services/core/java/com/android/server/am/ProcessList.java +7 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,13 @@ final class ProcessList { // without empty apps being able to push them out of memory. static final int MIN_CACHED_APPS = 2; // Min aging threshold in milliseconds to consider a B services for propagation to higher adj static final int MIN_BSERVICE_AGING_TIME = SystemProperties.getInt("ro.sys.fw.bservice_age",5000); // Threshold for B Services when in memory pressure static final int BSERVICE_APP_THRESHOLD = SystemProperties.getInt("ro.sys.fw.bservice_limit",5); // Enable B service aging propagation on memory pressure. static final boolean ENABLE_B_SERVICE_PROPAGATION = SystemProperties.getBoolean("ro.sys.fw.bservice_enable",false); // The maximum number of cached processes we will keep around before killing them. // NOTE: this constant is *only* a control to not let us go too crazy with // keeping around processes on devices with large amounts of RAM. For devices that Loading