On Android, in fact, there is a complete set of memory management mechanism. But because we are poisoned by Windows and Symbian, it's very uncomfortable to see the rest of the phone's memory only 30m, and we always want to clean up the memory with some tools, and when the toast shows that you've cleaned up 500m of memory, it's going to be incredibly pleasurable. For example, the housekeeper's small rocket launch, is to take advantage of this user mentality.
So, those memory cleanup tools are necessary on Windows, but on Android, it's superfluous. As for the priority of the process and the Memorykiller management mechanism, the system is managed through OOM_ADJ, which can be learned in more detail by an email from the previous applet.
On Android, there are 6 major types of processes, namely Foregroud, visible, secondary server, hidden, content provider, and empty. They are killed with priority, Emtpy > Content provider > Hidden > Secondary server > Visible > Foreground. Each type of process, the system has a threshold, and once the threshold value reaches the maximum threshold, it will follow the above sequence process cleanup process.
For example, for example, the strategy is 6m, 8m, 16m, 20m, 22m, 24m, when the system remaining memory is 22m, will first clean up the empty process, if after the cleanup, if the remaining memory is still sufficient 24m, then continue to clean up the content provider process, and so on, Until the remaining memory reaches more than 24m.
Depending on the role of the various processes and the type of user, we can configure various memory allocation modes:
1) for a long time only focus on an application, such as games, browsers, etc.-geek mode;
2) need to jump in multiple applications, such as QQ, browser, etc.--changeable mode;
3) Only focus on calls, SMS, mail and other business-business model;
4) and so on.
In the case of root, these six values can be dynamically modified by modifying the system file/sys/module/lowmemorykiller/parameters/minfree.
Here is a brief introduction to the role of these six types of processes, found on the Internet:
- Foreground process (foreground): The process 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.
- 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)
- Secondary services (secondary server): Some of the services currently running (major services, such as dialing, are not likely to be terminated by 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
- 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.
- Content 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
- 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 boot speed or record some history of the program information. This part of the process is undoubtedly the first to be terminated.
When the phone remaining memory comparison, the phone becomes slow, because the emtpy process threshold is set too low, causing the system to be low in the memory of the situation, only to start the cleanup process. The overall system compares cards when the remaining memory is low but has not yet reached the condition to clean up the memory.
Therefore, our strategy is mainly to solve two aspects of the problem:
1. Raise the upper limit of the threshold, empty more space, in order to improve the overall operating speed of the system;
2. The threshold of each process should be opened to form a gradient, making the process management mechanism more effective work;
Optimization of memory allocation policy on Android