Android Process Management (detailed)

Source: Internet
Author: User

The principle of Android-don't need too much memory left


Don't worry about the size of the remaining memory. In fact, a lot of people are using other systems to bring the habit to come. Android most applications do not exit the design is actually reasonable, and the system on the process of the scheduling mechanism has a relationship. If you know Java, Can be clearer about this mechanism. In fact, similar to Java's garbage collection mechanism, the system has a rule to reclaim memory. There is a threshold for memory scheduling, only below this value the system will press a list to shut down what the user does not need. Of course, this value is set to a small default, So you'll see that memory is old in very few numbers hovering. But in fact he does not affect speed. Instead, it accelerates the next time the app is launched. This is one of the advantages of Android, and it is not necessary to shut down the process. In particular, software that automatically shuts down the process.

Someone here will say, why is it slow to run a large program when memory is low? In fact, it is very simple, in the memory of a long time to open a large program, will trigger the system's own process scheduling policy, which is very consumption of system resources operation, Especially when a program frequently requests memory from the system. In this case the system does not shut down all open processes, but selectively shuts down, and frequent scheduling naturally slows down the system. Therefore, there is a program on the forum to change the memory threshold can be a certain improvement. However, changes can also cause some problems, depending on the setting of the value.
So, is there any need for process management software? You can manually turn off some processes to free up memory before running a large program, which can significantly improve your running speed. But some small programs can be completely managed by the system itself. When it comes to this, maybe some friends will ask, If you do not shut down the program will be more power consumption. I'll just talk about the fundamentals of Android backstage, and you'll understand. Android Android app is actually paused when it is switched to the background, and does not consume CPU resources. Only the running state is preserved. So why do some programs cut out to re-enter the main interface. However, if a program wants to process something in the background, such as music playback, it will open a service. The service can continue to run in the background, so there are only applications with services in the background. This can be seen in the process management software, The label is a service. As for the broadcast, I'm not involved. So no application with a service in the background is completely power-hungry, there is no need to shut down. This design is a very good design, the next time you start the program, it will be faster, because there is no need to read the interface resources, What is the need to turn off the advantages of this android?
there's one more. Why Android is an app that looks like it consumes memory. As you know, Android apps on Android are Java, which of course requires virtual machines, and Android apps with standalone virtual machines That is, each application opens a separate virtual machine. This is designed to avoid crashes of the virtual machine, which can cause the entire system to crash, but at the cost of more memory.

These designs ensure the stability of Android and, under normal circumstances, up to a single program crashes, but the whole system does not crash, and there is never a hint of out-of-memory. People may be too poisoned by windows, always want to keep more memory, but in fact this does not necessarily increase speed, On the contrary, it is not necessary to lose the system feature of the fast program launch. You might as well use this system as I say. Finally recommend a process management software, Systempanel,market can search, interface friendly start fast, function is good, for manual shutdown process very good software. Good luck to everyone, this system is open for 10 days and half a month is no problem, not windows.


As for why the switch slows down after a large program or several programs, I understand the following:
1. Big program A has been turned on, occupy 70% of memory, if you want to run a B, need 50% of memory, you need a to release a from memory or compression process, so the show is a slow moment
2.a\b\c\d\e A total of memory 80%, running the new program Z requires 20% of memory, system memory because you have not seen the remaining 0, that is, there should be a portion of free memory, then you need to choose one or a few from the A~e program to close, this process also needs to consume system resources, So it's going to be slow .
3. That is, when you manually kill the program, is to release memory for the system, even if you do not kill, in the need for memory when the system will be automatically released.
4. Programs not running in the background (no service), even if you do not kill the power consumption. Running in the background (a service) program, such as singing in the background, of course, power consumption.
5. Not that the killing process is useless, otherwise the author will not recommend the process management software. Which one with the service power consumption which background has been running, see the service can see, such a Kill.
6, to QQ example, the normal retreat, will leave the running state of QQ in the process management, but not the power consumption does not account for the CPU, if you just switch out (according to the small house rather than exit) then natural power consumption, because the program is still running.

(QQ backstage as the background is the normal exit of QQ and other software like not completely quit will be in memory, but does not account for the CPU does not charge the power to start again will be very fast this is why Android can surpass the WM6 system reason)



simple talking about the difference between the house key and the exit key, a mild study of the memory management of the phone!!!


When running a program, click the House key can be back to the desktop, generally click the Exit button can also be retired to the desktop, what is the difference between the two?

In fact, there is a difference, you should be based on your own needs flexible choice

Press the House key, it seems to be out, but in fact the software is not closed, but instead to aBackground Program(refers to the general software, does not discuss the special kind of software)

Press the exit key and it looks like it's quitting right, but this software is actually turned intoVacancy Procedures(except music, music belongs to special software with service)

Let's take a look at the level of all Android 5 program processes, the empty process is the lowest, it is the purpose of the next time to open the software can be more convenient and fast (this is a good design purpose), and once you need to clean up more memory space, it is the system automatically the highest priority to clear


System process level diagram, the lower the level, the sooner the sooner the system is intelligently cleaned out


So, do you understand? If you need to exit the software, if there is no software to provide the Exit function, then try to exit with the exit key instead of the house key, and,Most importantly, there is no need to use process management software to actively clean up the empty process, because it is to be cleaned up, but before it is cleaned up, but also can play the role of rapid re-opening, once you voluntarily clean up, and even this advantage is not, then, Why should the designer of the Android system design this vacant program? Isn't it better to just free up memory? So, the conclusion is, since it exists, there is the benefit of its existence! Let us enjoy this benefit! using Process Management initiative to clear the empty program is definitely against the Android system design intent, is a ridiculous silly practice!




again, the House key.

As we all know, Android and the iphone, our Gphone is a typical multi-tasking system, since it is a multi-tasking system, then naturally there will be a multi-tasking between the need to switch, then will everyone really this operation?

At this time, you need to use the House key, in a program, such as short messages, see a few words do not know, then you can select the text, and then copy, press the house key switch to the desktop, and then open the dictionary, paste, query, Check well and then long press the House key (long press the role of a few open programs and recently opened between the program switch), switch back to the text message, this time the short message program does not need to reopen the interface you just now, you can copy and then long press the switch dictionary to continue to query the next word ....

This is the use of the House key, in fact, we all know this usage, but probably did not consider the fact that this is a process of switching between the front and back of the program just ...




Finally, a simple summary of all the content, in fact, the whole article means that, press the exit key equivalent to the "real" exit close the program, press the House key, it seems to be closed the program, but in fact, is only a false impression, the program is only reduced only "a" a level, the house is more suitable for multi-task switching It's so simple ...


About the principles of Android memory management, and related automatic memory management software principles


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. XDA of the landlord and further research on this management mechanism, with the following findings:

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 (the system will determine which processes need to end according to "Oom_adj"), in general, the greater the value of "Oom_adj", The process is selected by the system to terminate the higher possible)

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

3.Android is different from Linux, has its own unique process Management module, this module is more customizable, can be based on the "Oom_adj" value of the scope to determine the process management policy, such as can be set "when memory is less than X, the end of" Oom_adj "greater than Y process". This gives the process management script the option to write more.

4.Android divides the process into six main categories:

1. 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.

2. Visible process (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)

3. 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

4. Background process (hidden): Although the author uses the word hidden, it is actually a background process (background), which 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.

5. Content Provisioning Node (contents provider): There is no program entity, to provide content for other programs to use, such as Calendar supply nodes, mail supply nodes. This type of procedure should have a higher priority when the process is terminated

6. Null 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.


Practice

To finish the theory, to say some practical things, how to manage the six kinds of processes, how to set the Process Management module is this part of the content.

The first is the software, it is recommended to use Minfreemanager, there is a download on the market, to set the management strategy of these six types of processes.

After running the software has six input boxes, in the input box can only enter numbers, these numbers represent the processing strategy of such processes, such as the input box under the foreground APP display 6, indicating that when the available memory is less than 6MB, terminate the foreground App. Similar to the following, such as the empty app under the input box display 24, it means that when the memory is less than 24MB, terminate the empty app.

From the setting of software values it is not difficult to see the finite order of the end process: Empty>content provider>hidden>secondary server>visible>foreground.

However, there are some problems with the default settings:
Various processes of the management strategy of the threshold is quite close: 6,8,16,20,22,24, the maximum difference is less than 8MB, in the actual program running, it is easy to cause a variety of types of processes are closed at the same time. If there is a 25 o'clock in the available, the sudden start of the camera program, the system can be quickly available memory, may result in empty processes, content supply nodes, background processes, secondary services, etc. are closed at the same time
Lower threshold: General mobile phone startup, the availability of 50-100 or so, but with the use of mobile phones, the available memory will gradually reduce, and finally reduced to about 24MB, then the system began to start the process management mechanism, began to end the process, but the valve limit is set at 24MB, relatively low. The result is that the overall speed of the system slows down after a period of time. Obviously, when the phone is used for a long time, the system reacts very slowly when the phone dials, albums, cameras and other applications are turned on.

Based on the above problems, it is not difficult to see that our revised target will be very clear, the main solution to two contradictions:
The threshold level of each process is opened, so that the process management mechanism can work more effectively.
Increase the upper threshold, empty more free memory, to improve the overall system operation speed

Process Management policy setting principles:
foreground processes, visible processes, and secondary services are content that is relevant to the user experience, and this part of the process management strategy is relatively conservative, leaving enough room for these processes to run
Squeezing useless processes, freeing up memory space for the main program to use

The following author summarizes several settings, to adapt to different use needs:
Gamer/Heavy Browser User configuration:
User characteristics: Long time to focus on a specific, high memory requirements of the program, the demand for multi-tasking is not high

Configuration parameters:

1.foreground:6
2.visible:8
3.Secondary server:16
4.Hiden app:80
5.Content provider:90
6.empty:100

Configuration concept: Press the background process, the content supply node and the empty process, to leave the memory as many as possible to the foreground process and the system, improve the game speed and the browser experience
Advantage: The fastest program starts and runs
Disadvantage: Multi-task processing is not ideal, the background process will be terminated when there are more open programs

Multi-task configuration:
User features: Running multiple applications at the same time requires frequent switching between multiple programs

Configuration parameters:

1.foreground:6
2.visible:8
3.Secondary server:16
4.Hiden app:20
5.Content provider:60
6.empty:100

Configuration concept: Squeeze empty process, to the content supply node to leave a certain space, maximize the use of background program space, improve the processing capacity of multitasking
Advantages: When running multiple programs, background programs are not easily terminated due to more disposable memory
Disadvantage: The speed of the program start and the overall system speed may be slightly slower than the game player configuration, due to the frequent operation of multitasking, usually the response speed of the system will be affected by certain
Mild User/Schoolgirl configuration
User features: The main function of the mobile phone is SMS and phone, occasionally with a camera selfie

Configuration parameters:

1.foreground:6
2.visible:8
3.Secondary server:16
4.Hiden app:24
5.Content provider:32
6.empty:48

Configuration concept: Squeeze empty process, to the content supply node to leave a certain space, maximize the use of background program space, improve the processing capacity of multitasking
Advantages: More balanced configuration, improve the system's available memory, so that the overall speed of the system has been improved, the level of management policy at all levels of the process, making the management mechanism more efficient
Cons: More balanced configuration, no obvious drawbacks

Android Process Management (detailed)

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.