// Now determine the memory trimming
level of background processes.
// Unfortunately we need to start at
the back of the list to do this
// properly. We only do this if the number of background
apps we
// are managing to keep around is
less than half the maximum we desire;
// if we are keeping a good number
around, we'll let them use whatever
// memory they want.
final int numCachedAndEmpty =
numCached + numEmpty;
int memFactor;
if (numCached <= ProcessList.TRIM_CACHED_APPS
&& numEmpty <=
ProcessList.TRIM_EMPTY_APPS)
{
if (numCachedAndEmpty <=
ProcessList.TRIM_CRITICAL_THRESHOLD)
{
memFactor =
ProcessStats.ADJ_MEM_FACTOR_CRITICAL;
} else if (numCachedAndEmpty
<= ProcessList.TRIM_LOW_THRESHOLD)
{
memFactor =
ProcessStats.ADJ_MEM_FACTOR_LOW;
} else {
memFactor =
ProcessStats.ADJ_MEM_FACTOR_MODERATE;
}
} else {
memFactor =
ProcessStats.ADJ_MEM_FACTOR_NORMAL;
}