OomMinFreeLow:
// These are the low-end OOM level limits. This is appropriate for an // HVGA or smaller phone with less than 512MB. Values are in KB. private final int[] mOomMinFreeLow = new int[] { 12288, 18432, 24576, 36864, 43008, 49152 };
OomMinFreeHigh:
// 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 };
OomMinFree列是通过算法计算的:
for (int i = 0; i < mOomAdj.length; i++) { int low = mOomMinFreeLow[i]; int high = mOomMinFreeHigh[i]; if (is64bit) { // Increase the high min-free levels for cached processes for 64-bit if (i == 4) high = (high * 3) / 2; else if (i == 5) high = (high * 7) / 4; } mOomMinFree[i] = (int)(low + ((high - low) * scale)); }
OomMinFree4K是写到LMDK里的值,计算方法:
// Memory pages are 4K. static final int PAGE_SIZE = 4 * 1024; (mOomMinFree[i] * 1024)/PAGE_SIZE
OomMinFree_abs:如果设置了
config_lowMemoryKillerMinFreeKbytesAbsolute就会通过以下算法计算,表格中OomMinFree_abs是设置为645120后得到的值。
if (minfree_abs >= 0) { for (int i = 0; i < mOomAdj.length; i++) { mOomMinFree[i] = (int)((float)minfree_abs * mOomMinFree[i] / mOomMinFree[mOomAdj.length - 1]); } }
OomMinFree_adj:如果设置了
config_lowMemoryKillerMinFreeKbytesAbsolute就会通过以下算法计算,表格中OomMinFree_adj是设置为645120后得到的值。
FOREGROUND_APP_ADJ | VISIBLE_APP_ADJ | PERCEPTIBLE_APP_ADJ | PERCEPTIBLE_LOW_APP_ADJ | CACHED_APP_MIN_ADJ | CACHED_APP_LMK_FIRST_ADJ | |
前台进程 | 可见进程 | 可感知进程 | 可感知进程低adj | 不可见进程最小adj | 不可见进程最大adj | |
OomAdj | 0 | 100 | 200 | 250 | 900 | 950 |
OomMinFreeLow | 12288 | 18432 | 24576 | 36864 | 43008 | 49152 |
OomMinFreeHigh | 73728 | 92160 | 110592 | 129024 | 147456 | 184320 |
OomMinFree | 73728 | 92160 | 110592 | 129024 | 221184 | 322560 |
OomMinFree4K | 18432 | 23040 | 27648 | 32256 | 55296 | 80640 |
OomMinFree_abs | 147456 | 184320 | 221184 | 258048 | 442368 | 645120 |
OomMinFree_adj | 221184 | 276480 | 331776 | 387072 | 663552 | 967680 |
minfree_abs | 645120 | -1 | ||||
minfree_adj | 645120 | 0 |