Posts

Showing posts with the label Android Memory Overview

Android Memory Overview [Part2] - Android LMKD

Image
Introduction In the last tutorial we saw the need and a high level overview of the Low Memory situations and different ways to understand and assign the processes a score which can be used to kill/not kill them when low mwmory conditions happen. Android uses lmkd [LowMemoryKiller Daemon] running in userspace to determine a low memory condition and kill processes as necessary. Let us see the details of the lmkd implementation. Android Low Memory Killer Daemon – Detailed Walkthrough. Android LowMemoryKillerDaemon Startup When Android’s init process parses init.rc, We can see that the memcg [memory cgroup] is initialized Again, Moving further the init.rc starts the lmkd service process. The source for the lmkd is located in  platform/system/memory/lmkd. https://android.googlesource.com/platform/system/memory/lmkd/ Let us look at the main function of the lmkd with some important items mark...

Android Memory Overview [Part1] - Introduction to Low Memory Killer

Introduction Inspite of the world seeing a flood of devices with ever increasing Memory hardware support [Even the low end Android Devices come equipped with ~2GB + of RAM], Android low memory conditions can happen because of various reasons.   Under these conditions the device may become unusable if certain operations to revive the low/no memory condition are not performed. We will in this series try and understand the LowMemoryKiller implemented by Android to overcome the conditions of Low/No Memory. Why the OOM-killer? Major distribution kernels set the default value of  /proc/sys/vm/overcommit_memory  to zero, which means that processes can request more memory than is currently free in the system. This is done based on the heuristics that allocated memory is not used immediately, and that processes, over their lifetime, also do not use all of the memory they allocate. Without overcommit, a system will not fully utilize its memory, thus wasting some...