Android Memory recovery mechanism

Source: Internet
Author: User
Tags home screen

Exit but do not close:
This is an Android optimized for Linux. When the Android application exits, it does not clean up the memory it consumes, and the Linux kernel process continues to exist, so-called "quit without shutting down". This allows the user to get a response at the first time when invoking the program.
App switching to the background is paused, completely CPU-and power-intensive, leaving only the running state. If the app requires background processing (music), then the app process turns on the service, so there's only a service consumed in the background.
Consumes CPU's application only consumes power, the backstage only occupies the memory, therefore is does not consume electricity.
Default Recycle mechanism:
When system memory is low, the system activates the memory reclamation process. In order not to affect the user experience (such as killing the current active process) due to memory reclamation,
Recycle priority:
Android based on the components running in the process and their status specifies the default five recycle priority:
Importance_foreground: The foreground process, the process currently being displayed on the screen, and some system processes.
Importance_visible: Visible process, visible process is some no longer the foreground, but the user still visible process, such as input method, weather, clock and so on.
Importance_service: Service processes, dialing, mail storage, and so on.
Importance_background: Background process, a process that is switched to the background after it is started.
Importance_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.
Home app: The desktop process, launcher, ensures that after a multi-task switch, you can quickly return to the home screen without reloading the launcher.
The importance of the process is evaluated and the importance is expressed as a value of "Oom_adj". The "Oom_adj" value of the foreground program is 0, which means it will not be terminated by the system.
Process management policies can be determined according to the range of "Oom_adj" values, such as "when memory is less than X, end" Oom_adj "process greater than Y".

threshold value for triggering memory reclamation:
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 very small by default, so you will see memory hovering in very few numbers.
Why it is slow to run a large program when memory is low, because when you open a large program in memory, it triggers the system's own scheduling policy, which consumes system resources, 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.
app virtual machine:
Android app is Java, of course, virtual machine, and Android Android app is with a standalone virtual machine, that is, every application opens a separate virtual machine. This is designed to avoid crashing the entire system, but at the cost of requiring more memory.
Home key and return key:
The home key is used for multi-task switching and the return key is equivalent to exiting the application.
Press home to exit, the program retains the status of the background process, press the return key to exit, the program holds the status of empty process.
Some mobile phone home button after the program restart:
(1) Modify Manifast as follows:
<activity android:name= "com.unity3d.player.UnityPlayerActivity" android:label= "@string/app_name" Android: Configchanges= "Fontscale|keyboard|keyboardhidden|locale|mnc|mcc|navigation|orientation|screenlayout|screensize |smallestscreensize|uimode|touchscreen "android:screenorientation=" Landscape ">
(2) Open a service in the background
(3) There is a way to set the app to never be added by Kill,androidmanifest.xml:
Android:persistent= "true"
This allows the application to be protected from out-of-memory killer
Applies to apps that are placed under/system/app.
<application android:name= "Phoneapp"
Android:persistent= "true"
Android:label= "@string/dialericonlabel"
android:icon= "@drawable/ic_launcher_phone" >
(4) Setting Runinbackground
(5) Qualitysettings.setqualitylevel
(6) Whether you can manually set the switch QQ login or Web mode login (memory over the hour)
(7) Using software Minfreemanager to set the threshold value of various processes triggering oom

Android Memory recovery mechanism

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