Android 7.0 LowMemoryKiller初対面


killログの(adj 900)
848: 11-10 16:21:21.424072 1114 21429 I ActivityManager: Killing 1029:com.google.process.gapps/u0a16 (adj 900): system app is not cached in devices with low memory

低メモリしきい値
主にこの2つのファイルですが、配置によって携帯電話の2つのファイルが違いますよ
/sys/module/lowmemorykiller/parameters/minfree /sys/module/lowmemorykiller/parameters/adj
C:\Users\fadi.su>adb shell cat /sys/module/lowmemorykiller/parameters/minfree
18432,23040,27648,32256,55296,80640

C:\Users\fadi.su>adb shell cat /sys/module/lowmemorykiller/parameters/adj
0,100,200,300,900,906

OOM_ADJ
minfree
minfree_MB
0
18432
18432 * 4 KB = 72 MB
100
23040
23040 * 4 KB = 90 MB
200
27648
27648 * 4 KB = 108 MB
300
32256
32256 * 4 KB = 126 MB
900
55296
55296 * 4 KB = 216 MB
906
80640
80640 * 4 KB = 315 MB
私のマシンはAndroid 7.0以前adj値がこんなに大きくなかったのを覚えていますが、0,1,2,7,14,15のイメージです.
したがって、システムの使用可能なメモリがminfree値より小さい場合、killに対応するOOM_ADJレベルのプロセスは、システムが使用可能なメモリが216 MB未満の場合、adj優先度が900の場合、killによって削除される
    // This is the process running the current foreground app.  We'd really
    // rather not kill it!
    static final int FOREGROUND_APP_ADJ = 0;

    // This is a process only hosting activities that are visible to the
    // user, so we'd prefer they don't disappear.
    static final int VISIBLE_APP_ADJ = 100;

    // This is a process only hosting components that are perceptible to the
    // user, and we really want to avoid killing them, but they are not
    // immediately visible. An example is background music playback.
    static final int PERCEPTIBLE_APP_ADJ = 200;

    // This is a process currently hosting a backup operation.  Killing it
    // is not entirely fatal but is generally a bad idea.
    static final int BACKUP_APP_ADJ = 300;

    // This is a process only hosting activities that are not visible,
    // so it can be killed without any disruption.
    static final int CACHED_APP_MAX_ADJ = 906;
    static final int CACHED_APP_MIN_ADJ = 900;

OOM_ADJ
定数表示
意味
0
FOREGROUND_APP_ADJ
現在使用中のフロントプロセス
100
VISIBLE_APP_ADJ
可視プロセス
200
PERCEPTIBLE_APP_ADJ
バックグラウンド音楽の再生など、感知可能なプロセス
300
BACKUP_APP_ADJ
バックアッププロセス
900
CACHED_APP_MAX_ADJ
非表示プロセスのadj最大値
906
CACHED_APP_MIN_ADJ
非表示プロセスのadj最小値
締めくくり
毛として、応用が殺された理由がだいたい分かった.しかし、具体的なADJの採点ルールはまだ検討されていない.出会ってからにしよう