The principle of Android memory management--process management

Source: Internet
Author: User

The principle of Android memory management--process management


Android takes a different process management strategy from Linux , and unlike Linux, which ends the process after the process activity has stopped, Android keeps the processes in memory until the system needs more memory. These processes, which are kept in memory, typically do not affect the speed of the overall system, and increase the startup speed of the process when the user activates the processes again.


When does Android end the process? Which process does it end?

The common understanding was that Android was based on a list of the most recently used programs called LRU(last recently used), sorted the program, and ended the oldest process. But there's actually more detail in it.


1.The importance of the process is evaluated and the importance is expressed in terms of the value "Oom_adj", which is given to each process, and the system is judged by "Oom_adj"
Which processes to end, in general, the higher the value of "Oom_adj", the higher the likelihood that the process will be terminated by system selection)

2.The "Oom_adj" value of the foreground program is 0, which means it will not be terminated by the system, and once it is inaccessible, it will get a higher "Oom_adj", the author speculated "Oom_adj"
The value is determined by the location of the software in the LRU list;

3.Unlike Linux, Android has its own unique process management module, which is more customizable and can determine the process management strategy based on the range of "Oom_adj" values, such as "when memory is less than X, end" Oom_adj "greater than Y". This gives the process management script the option to write more.

4.Android divides the process into six major categories:

First,Foreground process (foreground): The process that is currently being displayed on the screen and some system processes. For example, a system process such as Dialer Storage,google Search is the foreground process, and for example, when you run a program, such as a browser, when the browser interface is displayed in the foreground, the browser belongs to the foreground process (foreground). But once you press home to return to the main screen, the browser becomes a daemon (background). The last process we want to terminate is the foreground process.

Second,Visible Processes (Visible): Visible process is some no longer the foreground, but the user is still visible process, for example: Widgets, Input method, etc., are visible. Although this part of the process is not in the foreground, but also closely related to our use, we do not want them to be terminated (you certainly do not want the clock, weather, news and other widgets are terminated, then they will not sync, you do not want the input method is terminated, or you need to restart input input every time)

Third,Secondary services (Secondary server): Some of the services currently running (major services, such as dialing, etc., are not likely to be terminated by the process management, so this is only a minor service), for example: Google Enterprise Suite, gmail internal storage, contact internal storage, and so on. Although this part of the service is a secondary service, but some of the system functions are still closely related, we often need to use them, so we also hope they are terminated

Four,Background process(background): It is the process that we generally understand to be switched to the background after startup, such as a browser, a reader, and so on. When the program is displayed on the screen, the process that he runs is the foreground process (foreground), and once we press home to return to the main interface (note that by pressing home, not pressing back), the program resides in the background and becomes the background process (background). Background process Management policy has a variety of: in a more positive way, once the program arrives in the background immediately terminate, this way will increase the speed of the program, but can not speed up the program to start again, there are more negative ways, as much as possible to retain the background program, although it may affect the speed of a single program, However, the speed is increased when you start a program that has started again. This will require users to find a balance based on their own usage habits.

Five,Content providers (content provider): There is no program entity, the provision of content for other programs to use, such as calendar providers, mail providers and so on. This type of procedure should have a higher priority when the process is terminated

Six,Empty process (Empty): There is nothing in the process of running, some programs, such as BTE, after the program exits, will still reside in the process of an empty process, the process is not any data running, the role is often to improve the program's next startup speed or record some of the history of the program information. This part of the process is undoubtedly the first to be terminated.

The principle of Android memory management--process management

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.