Understanding application priorities and process state

Source: Internet
Author: User

Which process is killed to reclaim resources is determined by the priority of the application in the process. The priority of the application is the same as the highest priority of its component.

When the priority of two applications is the same, the process that has been in the lower priority for a long time will be killed first. The priority of a process is also affected by inter-process dependencies, and if one application relies on the service or content provider of another application, the application that provides the service is at least as high a priority as the application that receives the service.

All applications run in memory until the system needs its resources to be allocated to other applications.

Figure 3-3 shows the priority tree, which is used to determine the order in which the application is terminated.

It is important to build the application correctly to ensure that it is prioritized for what it does. If you do not do this, your application may be killed at certain important times.

The following list describes in detail the status of the application shown in Figure 3-3, explaining how the component determines the state:

? Active Process

An Active (foreground) process is an application that is dependent on the processes that contains the components that are currently interacting with the user. These are the processes by which Android tries to protect the ongoing responsiveness by reclaiming resources. In general, rarely have a process like this, they are finally killed.

Active process includes:

? Activity in the "active" state, which runs in the foreground to respond to user events. In this chapter, you will see more details about the status of the activity.

? Activity, Service, or broadcast Receiver that is executing the OnReceive event handler function.

? The service that is executing the Onstart,oncreate,ondestroy event handler function.

? Visible Process

Visible but inactive processes are those that have "visible" activity. By name, "visible" activity is the activity that is visible on the screen, but not in the foreground or in response to user events. This happens when an activity is partially obscured (by a non-full-screen or transparent activity). In general, and rarely have visible processes, they are only killed in extreme cases to ensure the operation of the active process.

? Started Service Process

The process is dependent on the service that has been started. The service continues to run in a dynamic manner without a visible interface. Because the service does not interact directly with the user, they have a lower priority than the visible process. They can also be thought of as foreground processes and will not be killed until resources are active/visible process requirements. You will learn the service in the 8th chapter.

? Background Process

The activity that is attached to the process is not visible and no service is started in the process, and these processes can be considered as background processes. In the system, there are a lot of background processes, and Android according to see first kill principle to kill the background process to get resources to the foreground process.

? Empty Process

To improve the performance of the entire system, Android often keeps applications in memory that have gone through the life cycle. Android maintains these caches to improve the start-up time of application restarts. These processes are often killed when resources are needed.

Understanding application priorities and process state

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.