1Android Low Memory Killer Daemon 2================================ 3 4 5Introduction 6------------ 7 8Android Low Memory Killer Daemon (lmkd) is a process monitoring memory 9state of a running Android system and reacting to high memory pressure 10by killing the least essential process(es) to keep system performing 11at acceptable levels. 12 13 14Background 15---------- 16 17Historically on Android systems memory monitoring and killing of 18non-essential processes was handled by a kernel lowmemorykiller driver. 19Since Linux Kernel 4.12 the lowmemorykiller driver has been removed and 20instead userspace lmkd daemon performs these tasks. 21 22 23Android Properties 24------------------ 25 26lmkd can be configured on a particular system using the following Android 27properties: 28 29 ro.config.low_ram: choose between low-memory vs high-performance 30 device. Default = false. 31 32 ro.lmk.use_minfree_levels: use free memory and file cache thresholds for 33 making decisions when to kill. This mode works 34 the same way kernel lowmemorykiller driver used 35 to work. Default = false 36 37 ro.lmk.low: min oom_adj score for processes eligible to be 38 killed at low vmpressure level. Default = 1001 39 (disabled) 40 41 ro.lmk.medium: min oom_adj score for processes eligible to be 42 killed at medium vmpressure level. Default = 800 43 (non-essential processes) 44 45 ro.lmk.critical: min oom_adj score for processes eligible to be 46 killed at critical vmpressure level. Default = 0 47 (all processes) 48 49 ro.lmk.critical_upgrade: enables upgrade to critical level. Default = false 50 51 ro.lmk.upgrade_pressure: max mem_pressure at which level will be upgraded 52 because system is swapping too much. Default = 100 53 (disabled) 54 55 ro.lmk.downgrade_pressure: min mem_pressure at which vmpressure event will 56 be ignored because enough free memory is still 57 available. Default = 100 (disabled) 58 59 ro.lmk.kill_heaviest_task: kill heaviest eligible task (best decision) vs. 60 any eligible task (fast decision). Default = false 61 62 ro.lmk.kill_timeout_ms: duration in ms after a kill when no additional 63 kill will be done. Default = 0 (disabled) 64 65 ro.lmk.debug: enable lmkd debug logs, Default = false 66 67 ro.lmk.swap_free_low_percentage: level of free swap as a percentage of the 68 total swap space used as a threshold to consider 69 the system as swap space starved. Default for 70 low-RAM devices = 10, for high-end devices = 20 71 72 ro.lmk.thrashing_limit: number of workingset refaults as a percentage of 73 the file-backed pagecache size used as a threshold 74 to consider system thrashing its pagecache. 75 Default for low-RAM devices = 30, for high-end 76 devices = 100 77 78 ro.lmk.thrashing_limit_decay: thrashing threshold decay expressed as a 79 percentage of the original threshold used to lower 80 the threshold when system does not recover even 81 after a kill. Default for low-RAM devices = 50, 82 for high-end devices = 10 83 84 ro.lmk.psi_partial_stall_ms: partial PSI stall threshold in milliseconds for 85 triggering low memory notification. Default for 86 low-RAM devices = 200, for high-end devices = 70 87 88 ro.lmk.psi_complete_stall_ms: complete PSI stall threshold in milliseconds for 89 triggering critical memory notification. Default = 90 700 91 92lmkd will set the following Android properties according to current system 93configurations: 94 95 sys.lmk.minfree_levels: minfree:oom_adj_score pairs, delimited by comma 96 97 sys.lmk.reportkills: whether or not it supports reporting process kills 98 to clients. Test app should check this property 99 before testing low memory kill notification. 100 Default will be unset. 101