Android: The howto app is not killed by the System

Source: Internet
Author: User
One way is to set the app to never be killed. Add Android: Persistent = "true" to androidmanifest. xml"
Applicable to apps stored in/system/APPAfter setting, the app is upgraded to the core level of the system and will not be killed in any case. The stop operation will also be blocked in settings-> applications. Proc #19 before setting: adj = svc/B 4067b028 255: COM. xxx. xxx/10001 (started-services)
# Cat/proc/255/oom_adj4 after setting pers #19: adj = Core/F 406291f0 155: COM. XXX. XXX/10001 (fixed)

# Cat/proc/155/oom_adj-12

 

The lowmemorykiller operation rule is as follows:

Write/sys/module/lowmemorykiller/parameters/adj

Write/sys/module/lowmemorykiller/parameters/minfree 2048,3072, 4096,6144, 7168,8192

 

After persistent is set, oom_adj =-12 will never be processed by lowmemorykiller.

 

Android: Persistent

Whether or not the application shocould remain running at all times-"true" if it shocould, and "false" if not. the default value is "false ". applications shocould not normally set this flag; persistence mode is intended only for certain system applications

 

Code

ActivityManagerService.java    final ProcessRecord addAppLocked(ApplicationInfo info) {        ProcessRecord app = getProcessRecordLocked(info.processName, info.uid);        if (app == null) {            app = newProcessRecordLocked(null, info, null);            mProcessNames.put(info.processName, info.uid, app);            updateLruProcessLocked(app, true, true);        }        if ((info.flags&(ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_PERSISTENT))                == (ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_PERSISTENT)) {            app.persistent = true;            app.maxAdj = CORE_SERVER_ADJ;        }        if (app.thread == null && mPersistentStartingProcesses.indexOf(app) < 0) {            mPersistentStartingProcesses.add(app);            startProcessLocked(app, "added application", app.processName);        }        return app;    }

The flag_system (/system/APP directory) and flag_persistent (Android: Persistent = "true ")

APP, set app. maxadj = core_server_adj (-12), and adj =-12 won't be processed by lowmemorykiller

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