Android如何减少lowmemory的发生几率[小内存]

 内存不足时常发生卡顿,甚至是死机重启问题,需要尽量减少内存不足情况的发生

1. 减少后台进程的数量

 修改 frameworks\base\services\core\java\com\android\server\am\ProcessList.java
 static final int MAX_CACHED_APPS = 32; // 改为 static final int MAX_CACHED_APPS = 8;

 或者:

 /frameworks/base/services/core/java/com/android/server/am/ActivityManagerConstants.java

 private static final int DEFAULT_MAX_CACHED_PROCESSES = 32;

2. 调整Low Memory Killer minifree门限值,frameworks\base\services\core\java\com\android\server\am\ProcessList.java中,
调整下面的mOomMinFreeHigh里面的后三项 ,分别增大1.1倍、1.2倍、1.5倍。
 // These are the high-end OOM level limits. This is appropriate for a
 // 1280x800 or larger screen with around 1GB RAM. Values are in KB.
 private final int[] mOomMinFreeHigh = new int[] {
       73728, 92160, 110592,
       129024, 147456, 184320
 };

你可能感兴趣的:(Android系统开发)