Beginning March 27, 2025, we advocate using android-latest-release instead of aosp-predominant to construct and contribute to AOSP. For more data, see Adjustments to AOSP. Low memory killer daemon Stay organized with collections Save and categorize content based on your preferences. The Android low memory killer daemon (lmkd) course of monitors the memory state of a running Android system and reacts to high memory stress by killing the least essential processes to maintain the system performing at acceptable ranges. An Android system running a number of processes in parallel might encounter conditions when system memory is exhausted and Memory Wave processes that require more memory experience noticeable delays. Memory strain, a state during which the system is operating brief on memory, requires Android to free memory (to alleviate the pressure) by throttling or killing unimportant processes, requesting processes to free noncritical cached resources, and so forth. Traditionally, Android monitored system memory pressure using an in-kernel low memory killer (LMK) driver, a inflexible mechanism that will depend on arduous-coded values.
As of kernel 4.12, the LMK driver is removed from the upstream kernel and the userspace lmkd performs memory monitoring and process killing duties. Android 10 and better support a brand new lmkd mode that makes use of kernel pressure stall data (PSI) displays for memory pressure detection. The PSI patchset within the upstream kernel (backported to 4.9 and 4.14 kernels) measures the period of time that duties are delayed as a result of memory shortages. As these delays immediately affect person experience, they characterize a handy metric for determining Memory Wave Routine stress severity. The upstream kernel additionally includes PSI screens that allow privileged userspace processes (equivalent to lmkd) to specify thresholds for these delays and to subscribe to events from the kernel when a threshold is breached. Because the vmpressure signals (generated by the kernel for memory pressure detection and utilized by lmkd) usually embrace quite a few false positives, lmkd must perform filtering to determine if the memory is below actual stress.
This leads to pointless lmkd wakeups and the usage of further computational sources. Using PSI monitors outcomes in more correct memory strain detection and minimizes filtering overhead. The default is true, making PSI displays the default mechanism of memory strain detection for lmkd. Low-RAM units had to be tuned aggressively, and even then would carry out poorly on workloads with giant file-backed energetic pagecache. The poor efficiency resulted in thrashing and no kills. The LMK kernel driver relied on free-memory limits, with no scaling primarily based on the memory pressure. Because of the rigidity of the design, companions usually customized the driver in order that it would work on their devices. The LMK driver hooked into the slab shrinker API, which wasn't designed for heavy operations similar to looking for targets and killing them, which slowed down the vmscan process. The userspace lmkd implements the identical performance because the in-kernel driver however uses current kernel mechanisms to detect and estimate memory strain. Such mechanisms embody using kernel-generated vmpressure occasions or pressure stall info (PSI) displays to get notifications about memory stress levels, and utilizing memory cgroup features to restrict the memory sources allocated to every course of primarily based on course of importance.
In Android 9 and higher, userspace lmkd activates if an in-kernel LMK driver is not detected. Userspace lmkd helps kill methods based on vmpressure occasions or PSI monitors, their severity, and different hints reminiscent of swap utilization. On low-memory devices, the system should tolerate larger memory stress as a standard mode of operation. On high-performance devices, memory pressure ought to be viewed as an abnormal scenario and mounted before it impacts general performance. Userspace lmkd additionally helps a legacy mode in which it makes kill selections using the identical methods as the in-kernel LMK driver (that is, free memory and file cache thresholds). Configure lmkd for a selected device utilizing the next properties. Android eleven improves the lmkd by introducing a brand Memory Wave Routine new killing strategy. The killing strategy makes use of a PSI mechanism for memory strain detection introduced in Android 10. lmkd in Android eleven accounts for memory resource use levels and thrashing to prevent memory starvation and efficiency degradation. This killing technique replaces previous methods and can be used on both excessive-performance and low-RAM (Android Go) devices. For low-RAM units, embrace memory cgroups. The memory killing strategy in Android 11 helps the tuning knobs and defaults listed beneath. These options work on each excessive-efficiency and low-RAM devices.