Android 进程回收
1.Android 进程回收策略
众所周知,Android是基于Linux系统的。在Android进程回收策略中,Android进程与Linux进程根据OOM_ADJ阈值进行区分:
- OOM_ADJ >= 4:比较容易被杀死的进程
- OOM_ADJ 0 ~ 3:不容易被杀死的进程
- OOM_ADJ < 0 :纯Linux进程,非Android进程
/**
* Activity manager code dealing with processes.
*/
final class ProcessList {
... // OOM adjustments for processes in various states: // Adjustment used in certain places where we don't know it yet.
// (Generally this is something that is going to be cached, but we
// don't know the exact value in the cached range to assign yet.)
// 未知进程,通常是用作缓存
static final int UNKNOWN_ADJ = ; // This is a process only hosting activities that are not visible,
// so it can be killed without any disruption.
// 拥有不可视的Activity的进程,可以不影响影响用户的情况下杀掉
static final int CACHED_APP_MAX_ADJ = ;
static final int CACHED_APP_MIN_ADJ = ; // The B list of SERVICE_ADJ -- these are the old and decrepit
// services that aren't as shiny and interesting as the ones in the A list.
// 一些旧的服务进程
static final int SERVICE_B_ADJ = ; // This is the process of the previous application that the user was in.
// This process is kept above other things, because it is very common to
// switch back to the previous app. This is important both for recent
// task switch (toggling between the two top recent apps) as well as normal
// UI flow such as clicking on a URI in the e-mail app to view in the browser,
// and then pressing back to return to e-mail.
// 用户使用的前一个进程
static final int PREVIOUS_APP_ADJ = ; // This is a process holding the home application -- we want to try
// avoiding killing it, even if it would normally be in the background,
// because the user interacts with it so much.
// 主界面进程
static final int HOME_APP_ADJ = ; // This is a process holding an application service -- killing it will not
// have much of an impact as far as the user is concerned.
// 持有应用服务的进程
static final int SERVICE_ADJ = ; // This is a process with a heavy-weight application. It is in the
// background, but we want to try to avoid killing it. Value set in
// system/rootdir/init.rc on startup.
// 重量级应用进程
static final int HEAVY_WEIGHT_APP_ADJ = ; // This is a process currently hosting a backup operation. Killing it
// is not entirely fatal but is generally a bad idea.
// 执行备份操作的进程
static final int BACKUP_APP_ADJ = ; // This is a process only hosting components that are perceptible to the
// user, and we really want to avoid killing them, but they are not
// immediately visible. An example is background music playback.
// 拥有用户可感知组件的进程
static final int PERCEPTIBLE_APP_ADJ = ; // This is a process only hosting activities that are visible to the
// user, so we'd prefer they don't disappear.
// 拥有用户仅可见、不可交互的Activity的进程
static final int VISIBLE_APP_ADJ = ; // This is the process running the current foreground app. We'd really
// rather not kill it!
// 前台运行的进程
static final int FOREGROUND_APP_ADJ = ; // This is a system persistent process, such as telephony. Definitely
// don't want to kill it, but doing so is not completely fatal.
// 系统常驻进程
static final int PERSISTENT_PROC_ADJ = -; // The system process runs at the default adjustment.
// 系统进程
static final int SYSTEM_ADJ = -; // Special code for native processes that are not being managed by the system (so
// don't have an oom adj assigned by the system).
// 为native进程保留,他们不被系统管理
static final int NATIVE_ADJ = -; ...
}
2.Android 进程被杀死情况
- 触发系统进程管理机制回收(Lowmemorykiller):这种方法会按照阈值从大到小进行清理
- 被没有进行Root的第三方应用杀死(使用killBackgroundProcess方法):这种方法只能杀死OOM_ADJ为4以上的进程
- 被进行Root的第三方应用杀死(使用force-stop或者kill):理论上来说可以杀死所有进程,但一般只会清理非系统关键进程和非前台可见进程
- 厂商的杀进程功能(force-stop或者kill):理论上来说可以杀死所有进程,包括Linux原生进程
- 用户主动“强行停止”进程(force-stop):只能停用第三方和非system/phone进程应用(停用system进程应用会造成Android系统重启)
Android 进程回收的更多相关文章
- Android内存管理篇 - 从updateOomAdjLocked看lowmemorykiller之外的Android进程回收机制
提起android的进程回收机制,大家所熟知的是Android的lowmemroykiller的机制.当系统可用内存低于某个阀值时,即会杀死这个阀值对应的Adj值的所有应用.但是本篇文章并为是要介绍L ...
- Android进程回收机制LMK(Low Memory Killer)
熟悉Android系统的童鞋都知道,系统出于体验和性能上的考虑,app在退到后台时系统并不会真正的kill掉这个进程,而是将其缓存起来.打开的应用越多,后台缓存的进程也越多.在系统内存不足的情况下,系 ...
- Android进程回收机制LMK(Low Memory Killer)【转】
本文转载自:http://www.cnblogs.com/wytiger/p/5744752.html 熟悉Android系统的童鞋都知道,系统出于体验和性能上的考虑,app在退到后台时系统并不会真正 ...
- Android进程回收的一些知识
关于OOM_ADJ说明: Android 进程易被杀死的情形: 参考:Android进程保活招式大全
- 【腾讯Bugly干货分享】Android进程保活招式大全
本文来自于腾讯bugly开发者社区,非经作者同意,请勿转载,原文地址:http://dev.qq.com/topic/57ac4a0ea374c75371c08ce8 作者:腾讯——张兴华 目前市面上 ...
- Android进程保活
Android进程回收机制 Low Memory Killer原理 微信团队原创分享:Android版微信后台保活实战分享(网络保活篇) 微信团队原创分享:Android版微信后台保活实战分享(进程保 ...
- Android 进程保活招式大全
目前市面上的应用,貌似除了微信和手Q都会比较担心被用户或者系统(厂商)杀死问题.本文对 Android 进程拉活进行一个总结. Android 进程拉活包括两个层面: A. 提供进程优先级,降低进程被 ...
- Android 进程保活招式大全(转载)
目前市面上的应用,貌似除了微信和手Q都会比较担心被用户或者系统(厂商)杀死问题.本文对 Android 进程拉活进行一个总结. Android 进程拉活包括两个层面: A. 提供进程优先级,降低进程被 ...
- 【转载】Android进程保活招式大全
原文地址:http://dev.qq.com/topic/57ac4a0ea374c75371c08ce8 目前市面上的应用,貌似除了微信和手Q都会比较担心被用户或者系统(厂商)杀死问题.本文对 An ...
随机推荐
- Vue中使用children实现路由的嵌套
Vue中使用children实现路由的嵌套 相关Html: <!DOCTYPE html> <html lang="en"> <head> &l ...
- 开源视频会议bigbluebutton
这是另一个开源视频会议项目,简称bbb 官方网站:http://bigbluebutton.org/ 代码地址:https://code.google.com/p/bigbluebutton/ dem ...
- CDH版本大数据集群下搭建Hue(hadoop-2.6.0-cdh5.5.4.gz + hue-3.9.0-cdh5.5.4.tar.gz)(博主推荐)
不多说,直接上干货! 我的集群机器情况是 bigdatamaster(192.168.80.10).bigdataslave1(192.168.80.11)和bigdataslave2(192.168 ...
- 初识Docker和安装
什么是Docker Docker的构想是要实现“Build,Ship and Run Any App,Anywhere”,即通过对应用的封装(Packaging).分发(Distribution).部 ...
- mysql修改存储过程的权限
直接上代码 grant execute on procedure 表名.存储过程名(eg: student.find) to '用户名'@'host'(eg: 'volumelicense'@'%') ...
- 桌面程序开发入门(WinForm with C#)
1.使用Visual Studio 2013创建新项目 2.创建一个主窗体和4个子窗体 3.创建一个数据库.一个表.一个存储过程 4.在配置文件里添加数据库连接字符串 5.真正的编码工作. 第一步:创 ...
- Hadoop+Hive 操作mongodb数据
Hadoop+Hive 操作mongodb数据 1.版本概述 hadoop-2.7.3.hive-2.2 下载响应的jar包:http://mvnrepository.com/,直接搜索想要的jar包 ...
- Hybrid混合式开发---回顾
一.前言 去年12月份开启了一个新项目--在线抓娃娃,就是让用户可以通过app去控制我们机房中的娃娃机来抓取娃娃.本项目开发半个月就紧急上线第一版本,中间经过2次大版本迭代,一个月不到就做到用户量超过 ...
- Java Bad version
Eclipse的三个地方需要重新设置: 在工程上点右键,选属性,三个地方: Java Build Path Java Compiler Project Facets:这个地方还可以设置tomcat的r ...
- How系列-公网如何ssh到内网的Linux系统中?
起因 最近碰到一件事:B同学在他电脑的Ubuntu虚拟机中学习搭建服务器碰到了问题,要我帮他看下.我总不能一个QQ远程桌面连过去,那样操作会卡到崩溃.ssh过去是最好的方法,不过他的电脑跟我不在一个局 ...