Oom_adj
When the memory is low, we always try to kill the background app and keep the persist service (such as the input method) as much as possible so that the foreground app can run smoothly.
1. The configuration of the background app is as high as possible, but before Max and Mini, try to keep some gaps so that the system can gradually kill the process,
Instead of killing a lot at a time. Killing many apps at a time can easily cause system freezing.
2. The previeous app and home launcer's adj must be independent and cannot be set too low. The previous app may occupy a lot of memory.
Swap
Swap is mainly used to set the threshold and when to trigger swap.
The main goal of swap is to supplement the memory in order to ensure the normal operation of the front-end app. For example, the browser is on a small memory machine.
Only two pages can be opened. If swap is enabled, five pages can be opened.
For other programs in the background, you do not need to use swap, because swap will reduce some performance, but try to kill too slowly to make front-end applications use physical memory as much as possible.
Therefore, the threshold value of swap is more suitable than that of the persist service. This ensures that necessary services still exist and the foreground applications can run normally.
CMA
Low memory killer is indeed a headache when calculating the remaining memory.
CMA is not free to use at any time. It may need to be allocated at the next time.
For CMA usage, the basic policy should still be used for the foreground app to ensure its operation. For background apps, do not calculate CMA as free.
If the current app does not need to use CMA-related drivers:
When all background apps are killed, CMA memory can be used. When a new app is started, the app will become a previous app,
However, the current memory is less free than the previous app requires, so it will be killed, and the CMA memory will be released without any problems.
If the current app uses CMA memory:
For example, the current activity will not be used, but the next acitivty may need to use CMA-related drivers. In this case, CMA cannot be used (or only some can be used ), because you don't know when the system will need CMA memory.
Is there a way to know if the current app uses CMA-related drivers?
It is unknown before the related Java classes are used, so currently it cannot be processed.
At present, CMA can only be used as a way to save memory.