Android 开机Process xxx (pid xxxx) has died问题分析

前言

准备面试其实已经准备了挺久了,当时打算面试准备了差不多以后,跟公司谈谈涨薪的事情,谈不拢的话,就年后直接找其他的公司。谁想到婚假还没休完,老板就在公司宣布了撤出上海的决定,愿意去深圳的就去,不愿意的就自己找工作,给了一个多月的时间找工作,就没有赔偿了,反正公司也没钱。悲哀….

幸好提前准备过,不过都是断断续续的今天看点这个,明天看点那个,三天打鱼两天晒网的,也没用心去准备.这下好了,直接到了最差的地步了,没办法,用心准备吧。

08-12 16:48:40.453 773 908 D ActivityManager: SVC-mBroadcastQueues: com.android.server.am.BroadcastQueue@29a50ece

Log出处:

frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java

final void appDiedLocked(ProcessRecord app, int pid, IApplicationThread thread) {

// First check if this ProcessRecord is actually active for the pid.

synchronized (mPidsSelfLocked) {

ProcessRecord curProc = mPidsSelfLocked.get(pid);

if (curProc != app) {

Slog.w(TAG, "Spurious death for " + app + ", curProc for " + pid + ": " + curProc);

return;

}

}

BatteryStatsImpl stats = mBatteryStatsService.getActiveStatistics();

synchronized (stats) {

stats.noteProcessDiedLocked(app.info.uid, pid);

}

if (!app.killed) {

Process.killProcessQuiet(pid);

Process.killProcessGroup(app.uid, pid);

app.killed = true;

}

// Clean up already done if the process has been re-started.

if (app.pid == pid && app.thread != null &&

app.thread.asBinder() == thread.asBinder()) {

boolean doLowMem = app.instrumentationClass == null;

boolean doOomAdj = doLowMem;

if (!app.killedByAm) {

Slog.i(TAG, "Process " + app.processName + " (pid " + pid

  • “) has died”);

mAllowLowerMemLevel = true;

} else {

// Note that we always want to do oom adj to update our state with the

// new number of procs.

mAllowLowerMemLevel = false;

doLowMem = false;

}

EventLog.writeEvent(EventLogTags.AM_PROC_DIED, app.userId, app.pid, app.processName);

if (DEBUG_CLEANUP) Slog.v(

TAG, "Dying app: " + app + ", pid: " + pid

  • ", thread: " + thread.asBinder());

handleAppDiedLocked(app, false, true);

if (doOomAdj) {

updateOomAdjLocked();

}

if (doLowMem) {

doLowMemReportIfNeededLocked(app);

}

} else if (app.pid != pid) {

// A new process has already been started.

Slog.i(TAG, "Process " + app.processName + " (pid " + pid

  • ") has died and restarted (pid " + app.pid + “).”);

EventLog.writeEvent(EventLogTags.AM_PROC_DIED, app.userId, app.pid, app.processName);

} else if (DEBUG_PROCESSES) {

Slog.d(TAG, "Received spurious death notification for thread "

  • thread.asBinder());

}

}

可以看到app.killedByAm = false,也就是说不是ActivityManager主动kill该应用,而是LowMemory的原因(for RAM)。

ProcessRecord里属性:

private final BatteryStatsImpl mBatteryStats; // where to collect runtime statistics

final ApplicationInfo info; // all about the first app in the process

final boolean isolated; // true if this is a special isolated process

final int uid; // uid of process; may be different from ‘info’ if isolated

final int userId; // user of process.

final String processName; // name of the process

// List of packages running in the process

final ArrayMap pkgList

= new ArrayMap();

ArraySet pkgDeps; // additional packages we have a dependency on

IApplicationThread thread; // the actual proc… may be null only if

// ‘persistent’ is true (in which case we

// are in the process of launching the app)

ProcessStats.ProcessState baseProcessTracker;

BatteryStatsImpl.Uid.Proc curProcBatteryStats;

int pid; // The process of this application; 0 if none

int[] gids; // The gids this process was launched with

String requiredAbi; // The ABI this process was launched with

String instructionSet; // The instruction set this process was launched with

boolean starting; // True if the process is being started

如何成为Android高级架构师!

架构师必须具备抽象思维和分析的能力,这是你进行系统分析和系统分解的基本素质。只有具备这样的能力,架构师才能看清系统的整体,掌控全局,这也是架构师大局观的形成基础。 你如何具备这种能力呢?一是来自于经验,二是来自于学习。

架构师不仅要具备在问题领域上的经验,也需要具备在软件工程领域内的经验。也就是说,架构师必须能够准确得理解需求,然后用软件工程的思想,把需求转化和分解成可用计算机语言实现的程度。经验的积累是需要一个时间过程的,这个过程谁也帮不了你,是需要你去经历的。

但是,如果你有意识地去培养,不断吸取前人的经验的话,还是可以缩短这个周期的。这也是我整理架构师进阶此系列的始动力之一。


成为Android架构师必备知识技能

Android 开机Process xxx (pid xxxx) has died问题分析_第1张图片

对应导图的学习笔记(由阿里P8大牛手写,我负责整理成PDF笔记)

Android 开机Process xxx (pid xxxx) has died问题分析_第2张图片

部分内容展示

《设计思想解读开源框架》

  • 目录
    Android 开机Process xxx (pid xxxx) has died问题分析_第3张图片
  • 热修复设计
    Android 开机Process xxx (pid xxxx) has died问题分析_第4张图片
  • 插件化框架设计
    Android 开机Process xxx (pid xxxx) has died问题分析_第5张图片
    《360°全方面性能优化》
    Android 开机Process xxx (pid xxxx) has died问题分析_第6张图片
  • 设计思想与代码质量优化
    Android 开机Process xxx (pid xxxx) has died问题分析_第7张图片
  • 程序性能优化
    Android 开机Process xxx (pid xxxx) has died问题分析_第8张图片
    [外链图片转存中…(img-n6voEFeB-1649749403914)]
    《360°全方面性能优化》
    [外链图片转存中…(img-aDemUjgP-1649749403914)]
  • 设计思想与代码质量优化
    [外链图片转存中…(img-JrbezTmy-1649749403915)]
  • 程序性能优化
    [外链图片转存中…(img-pc3n3CB9-1649749403915)]
    Android开发不会这些?如何面试拿高薪!

你可能感兴趣的:(Android,经验分享,面试,android)