主要看这个类:ApplicationExitInfo
reason类型:一共13种
- 主要原因
/**
* Application process died due to unknown reason.
* 未知原因,不好解释,需要开发者自己去研究
*/
public static final int REASON_UNKNOWN = 0;
/**
* Application process exit normally by itself, for example,
* via {@link java.lang.System#exit}; {@link #getStatus} will specify the exit code.
*
*
* <p>Applications should normally not do this, as the system has a better knowledge
* in terms of process management.</p>
* 系统自己触发退出; 比如java的 System#exit,或者指定 exit code,比如物理键上的操作code
*/
public static final int REASON_EXIT_SELF = 1;
/**
* Application process died due to the result of an OS signal; for example,
* {@link android.system.OsConstants#SIGKILL}; {@link #getStatus} will specify the signal
* number.
* 系统退出
*/
public static final int REASON_SIGNALED = 2;
/**
* Application process was killed by the system low memory killer, meaning the system was
* under memory pressure at the time of kill.
*
* <p class="note">
* Not all devices support reporting {@link #REASON_LOW_MEMORY}; on a device with no such
* support, when a process is killed due to memory pressure, the {@link #getReason} will return
* {@link #REASON_SIGNALED} and {@link #getStatus} will return
* the value {@link android.system.OsConstants#SIGKILL}.
*
* Application should use {@link android.app.ActivityManager#isLowMemoryKillReportSupported()
* ActivityManager.isLowMemoryKillReportSupported()} to check
* if the device supports reporting {@link #REASON_LOW_MEMORY} or not.
* </p>
* 内存不足了,这个,我们作为开发者要注意: adj
*/
public static final int REASON_LOW_MEMORY = 3;
/**
* Application process died because of an unhandled exception in Java code.
* java 层未处理的carsh
*/
public static final int REASON_CRASH = 4;
/**
* Application process died because of a native code crash.
* native 层未处理的carsh
*/
public static final int REASON_CRASH_NATIVE = 5;
/**
* Application process was killed due to being unresponsive (ANR).
* 程序中的anr
*/
public static final int REASON_ANR = 6;
/**
* Application process was killed because of initialization failure,
* 初始化失败,
* for example, it took too long to attach to the system during the start,
* or there was an error during initialization.
*/
public static final int REASON_INITIALIZATION_FAILURE = 7;
/**
* Application process was killed due to a runtime permission change.
* 运行时权限修改
*/
public static final int REASON_PERMISSION_CHANGE = 8;
/**
* Application process was killed by the system due to excessive resource usage.
* 过度使用资源;
*/
public static final int REASON_EXCESSIVE_RESOURCE_USAGE = 9;
/**
* 用户操作的退出
* Application process was killed because of the user request, for example,
* 例如 : 用户点击强制退出按钮
* user clicked the "Force stop" button of the application in the Settings,
* or removed the application away from Recents.
*/
public static final int REASON_USER_REQUESTED = 10;
/**
* Application process was killed, because the user it is running as on devices
* with mutlple users, was stopped.
* 多用户切换
*/
public static final int REASON_USER_STOPPED = 11;
/**
* 需要依赖的资源不见了,也会触发退出
* Application process was killed because its dependency was going away, for example,
* a stable content provider connection's client will be killed if the provider is killed.
*/
public static final int REASON_DEPENDENCY_DIED = 12;
subreason: 一共 17 种
- 次要原因
/**
* Application process kills subreason is unknown.
*仅限内部使用的一些资源
* For internal use only.
* @hide
*/
public static final int SUBREASON_UNKNOWN = 0;
/**
* Debug 中,开发者主动退出
* Application process was killed because user quit it on the "wait for debugger" dialog;
* this would be set when the reason is {@link #REASON_OTHER}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_WAIT_FOR_DEBUGGER = 1;
/**
* 有太多的缓存进程
* Application process was killed by the activity manager because there were too many cached
* processes; this would be set only when the reason is {@link #REASON_OTHER}.
*
* For internal use only.subreason
* @hide
*/
public static final int SUBREASON_TOO_MANY_CACHED = 2;
/**
* activity manager 杀的;空进程太多了;可以看一下android的5种进程划分;
* Application process was killed by the activity manager because there were too many empty
* processes; this would be set only when the reason is {@link #REASON_OTHER}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_TOO_MANY_EMPTY = 3;
/**
* activity manager 杀的;空进程的时间太长了;
* Application process was killed by the activity manager because there were too many cached
* processes and this process had been in empty state for a long time;
* this would be set only when the reason is {@link #REASON_OTHER}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_TRIM_EMPTY = 4;
/**
* activity manager 杀的;
* 系统有了内存压力,同时,这个进程持有了大量的缓存;
* Application process was killed by the activity manager because system was on memory pressure
* and this process took large amount of cached memory;
* this would be set only when the reason is {@link #REASON_OTHER}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_LARGE_CACHED = 5;
/**
* activity manager 杀的;从上次空闲以后,一直是处于低内存的压力
* Application process was killed by the activity manager because the system was on low memory
* pressure for a significant amount of time since last idle;
* this would be set only when the reason is {@link #REASON_OTHER}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_MEMORY_PRESSURE = 6;
/**
* activity manager 杀的;过度使用CPU
* Application process was killed by the activity manager due to excessive CPU usage;
* this would be set only when the reason is {@link #REASON_EXCESSIVE_RESOURCE_USAGE}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_EXCESSIVE_CPU = 7;
/**
* 系统以后,系统更新进程是要被杀掉的
* System update has done (so the system update process should be killed);
* this would be set only when the reason is {@link #REASON_OTHER}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_SYSTEM_UPDATE_DONE = 8;
/**
* 杀死所有的前台服务;为了managed profile ,进入quite mode
* Kill all foreground services, for now it only occurs when enabling the quiet
* mode for the managed profile;
* this would be set only when the reason is {@link #REASON_OTHER}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_KILL_ALL_FG = 9;
/**
* 现在它只发生当默认显示的密度改变时;
* All background processes except certain ones were killed, for now it only occurs
* when the density of the default display is changed;
* this would be set only when the reason is {@link #REASON_OTHER}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_KILL_ALL_BG_EXCEPT = 10;
/**
* 这个进程关联的UID被显示的杀死了;
* The process associated with the UID was explicitly killed, for example,
* it could be because of platform compatibility overrides;
* this would be set only when the reason is {@link #REASON_OTHER}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_KILL_UID = 11;
/**
* 直接了当的被指定pid后,杀死;通常来说,是因为低内存
* The process was explicitly killed with its PID, typically because of
* the low memory for surfaces;
* this would be set only when the reason is {@link #REASON_OTHER}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_KILL_PID = 12;
/**
* 启动了失效进程
* The start of the process was invalid;
* this would be set only when the reason is {@link #REASON_OTHER}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_INVALID_START = 13;
/**
* 进程处于一种无效状态,从而被杀;
* The process was killed because it's in an invalid state, typically
* it's triggered from SHELL; 通常是shell 脚本
* this would be set only when the reason is {@link #REASON_OTHER}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_INVALID_STATE = 14;
/**
* 模棱两可,可有可无的状态
* The process was killed when it's imperceptible to user, because it was
* in a bad state;
* this would be set only when the reason is {@link #REASON_OTHER}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_IMPERCEPTIBLE = 15;
/**
* 正常退出,被移除了LRU list;
* The process was killed because it's being moved out from LRU list;
* this would be set only when the reason is {@link #REASON_OTHER}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_REMOVE_LRU = 16;
/**
* 孤立和缓存状态
* The process was killed because it's isolated and was in a cached state;
* this would be set only when the reason is {@link #REASON_OTHER}.
*
* For internal use only.
* @hide
*/
public static final int SUBREASON_ISOLATED_NOT_NEEDED = 17;
Pss
- 进程已使用的内存的最后比例集大小(以 kB 为单位)
Rss
- 进程使用的内存的 最后驻留集大小(以 kB 为单位)