Theory
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
Summarize
elaborated the memory management mechanism, and recommended some configuration parameters, but these parameters do not necessarily apply to everyone, you can also adjust the settings of these parameters according to their actual usage habits.
============================================================================================================ We've been hearing about Android is a multi-process operating system, how does it handle every process?
You may have found that Android itself does not have the so-called shutdown process, and we can only press the "Back button" whenever we want to quit a process and go back to the desktop/open another program. And when we press the "Back" button, the process is not actually closed and is still stored in memory. This allows the program to be opened more quickly at the next call.
To really close an open process, in addition to using third-party software (such as Advanced Task Manager), there is another, that is, when the Android system thought that there was not enough memory to run the new process, need to close some although it is open, but no use ( Exactly how a process will be considered by the Android system as "no use" is discussed below.
And the next thing to look at is the Android internal Lowmemorykiller.
Activitymanagerservice.java records the priority of each process. The Oom_adj value of a process also represents its priority. A higher Oom_adj value means that the process has a lower priority. The Oom_adj value of a process being used is 0, and once we press the back key, the process gets a higher Oom_adj value (lower priority). The exact amount depends on the location of the process in the LRU (last recently used) list. (not confirmed)
Specific details are saved in the Android source file drivers/misc/lowmemorykiller.c.
Android divides the process into 6 levels, which are ranked from highest to lowest in order of precedence:
1. Foreground_app:
This is the process running the foreground app. We ' d really rather not kill it!
The program that the user is using. This setting is too high, the user can see is a program that is being used inexplicably disappeared, and then automatically back to the desktop. (because it was killed by the system.) So it's best not to touch it.
2. Visible_app:
This is a process of only hosting activities that is visible to the user, so we ' d prefer they don ' t disappear.8 B2]; P5 N; S
Similar to Foreground_app, users are using/seeing. The difference is that Visible_app may not be a user focus program, but the user can see it or not overwrite the entire screen, only part of the screen. So can be appropriately higher than the Foreground_app a little.
3. Secondary_server:
This is a process holding a secondary server--killing it'll not has much of an impact as far as the user is concerned .
Service for all apps. System-level service such as Phoneservice does not fall into this category, and they are never ended by Android. So this can be properly set up a little bit ~ Note that HOME (SENSEUI) is also included here so do not set too high. Every time you return to your desktop, you have to wait for it to load again, especially if you have more widgets.
4. Hidden_app:
This is a process of only hosting activities, and so it can be killed without any disruption.
Originally belongs to 1 or 2 of the program, in the user pressed "back" or "home" after the program itself can not see, but actually still running the program, they belong to Hidden_app. There is no effect on killing. But to understand that not all belong to this category should be finished immediately, such as push Mail,locale, alarm clock, etc. belong to this category. So don't set it too high. A program that really "should" return keys on the exit (a really useless program) is below.
5. Content_provider:
This was a process with a content provider that does not having any clients attached to it. If it has had any clients, its adjustment would is the one for the highest-priority of those processes.
The difference between the 5,6 and the concrete is not quite understood. It's not very useful, but it's a little bit more than Empty_app. So the highs don't matter ~
6. Empty_app:
This was a process without anything currently running in it. Definitely the first to go! This value was initalized in the constructor, careful when refering to this static variable externally.
A completely useless one, kill it only benefits no harm, first dry it
View the settings now to:
1. # Cat/sys/module/lowmemorykiller/parameters/minfree
Copy Code '
The display should be 6 digits separated by commas, for example:
1536,2048,4096,5120,5632,6144
Note that the units for these numbers are page. 1 page = 4 kilobyte.;
The above six numbers correspond to (MB): 6,8,16,20,22,24
These numbers are the corresponding memory thresholds, and once they are below this value, Android starts to close the process sequentially. So Android starts to end with the lowest priority Empty_app when available memory is less than 24MB (6144*4/1024).
One thing that doesn't make sense is that the available memory doesn't know where to get it. Obviously not the free memory available, and it looks like Compcache and swap are not affected.
To reset the value:
1. # echo "1536,2048,4096,5120,15360,23040" >/sys/module/lowmemorykiller/parameters/minfree
Copy Code
This will start the end of Empty_app when the available memory is below 90MB. The Content_provider group starts to end when the available memory is below 60MB. The rest of the four are not moving.
Attention:
The value changed by the above method is not permanent. After the next restart, the previous settings are restored. If you want the settings to be executed at each boot, the
1. Echo "1536,3072,4096,21000,23000,25000" >/sys/module/lowmemorykiller/parameters/minfree
Copy Code
Add to any of the boot-up configuration files. Files that are normally under/SYSTEM/INIT.D are performed on boot (some ROM may not be here.) just open any file in Notepad and add it to the line.
The original author made an application, in the market free, let everyone change the settings more convenient, called "Minfreemanager".
The figures given above are for reference only, the exact number is the optimal combination is under study.
Perhaps people do not understand the benefits of doing so. The advantage is that we have enough memory at any time to execute the program we want to run, and those really useless processes don't take up valuable memory. What's more, all of this is done without your involvement or assistance from any third party software, and is fully automated by Android in the background. Imagine, who will be more familiar with Android than the master of each process is more clever than the memory management program Silly Yiguoduan method ~ Let's start by deleting the memory management program from now on article source URL: http://bbs.23dopod.com/ viewthread.php?tid=17887