Powered By Blogger

Sonntag, 17. November 2013

(About)Android Memory Management

Android Memory Management 

Most of you must be knowing what Multi-tasking is all about. But this lil overview will take you inside the mechanics of Multi-tasking and give you a closer look.  Lets start off with a basic definition :

Multi-tasking is the ability to run various programs/applications simultaneously in such a way that the user can switch between these programs/applications  at will without  any of the processes being killed.

You all must have heard that different devices have different multi-tasking abilities. And sometimes, even different devices of same models have different multi-tasking abilities. Ever wondered why? Well this is simply because multi-tasking is directly related to the RAM of the device. Its depends on the amount of  RAM ,RAM usage as well as RAM usage management.

Since Android is a Linux system, it has an in-built task killer named as LowMemoryKiller(LMK). The LMK keeps an eye on the RAM usage of all applications in real-time, and when the system has too much RAM consumption, the LMK will start killing apps to free-up some memory. But the way it does that is defined through different sets of  groupings and values but in common terms , you might call these priorities, just the difference that  these priorities are more than simple order.

The LMK distinguishes apps by putting them under categories. Which app will get killed first depends upon the category in which it falls in and the minimum memory threshold of that category. Confused? Let me describe it with the below.





.
Suppose there are m apps which are being run, The LMK divides all the apps into 6 categories (Out of memory groupings). These have been explained briefly with their decreasing priority

1. Foreground Application - An app that you currently see on the screen. This also includes system and phone.
2.Visible Application - An app that is visible to the user but not at the front possibly because of transparency etc.
3. Secondary Server  - These are applications and services running in the background, it includes launcher, UI etc.
4. Hidden Application - Apps that are not visible but are still running in the background.
5. Content Provider – Processes that provide content for others, examples – Contacts, calender etc.
6. Empty Application - Apps that are essentially in standby and are not doing any work. They can be shut down.
All of these categories have a Minfree Threshold memory value. Whenever the free/Available memory of the system(x) gets less than any of the minfree values, then the LMK starts killing the apps which fall into the category whose minfree threshold value is more than the available memory according to the priorities of the groupings. For example – if  X  is less than memory 2, then the LMK starts killing apps in category 2 to free memory. Obviously, if the available memory is less than the minfree values of more than 1 category, then LMK kills the apps of the category which has the lowest priority first to free up memory.
So, this is how Android manages its memory and now I will explain how it affects the multi-tasking abilities of your Android. As you must have already understood that the in-built memory manager ( LMK) kills app of a specific category only if the available memory is less than the category’s minfree values. If the minfree value is more, then the apps under this category will get killed faster which implies poor multi-tasking whereas if the minfree value is small, the app will not be killed for a longer duration of time until the available memory is less than the small minfree value which leads to better multi-tasking. As default, the minfree values are inversely proportional to the priority of the category i.e. Minfree value of  Foreground Applications < Visible Applications < Secondary Servers < Hidden Applications < Content Providers < Empty Applications.
                                MANY GREEEEETZ AND DONT FORGET TO STAY ADDICTED!!!
                                                                        -CALIBAN666-

Keine Kommentare:

Kommentar veröffentlichen