Chrome 手机浏览器的进程生命周期,国内的浏览器能做到这个地步就可以了

移动应用的生命周期,我觉得 chrome 的表现非常好,这里大概展示一下:

com.android.chrome     基本进程,还没有研究它是做什么的

com.android.chrome:sandboxed_process0   空白tab对应的进程

com.android.chrome:sandboxed_process[1~n] 正常页面对应的进程名称。 但是并不像 PC 浏览器一样是每个 TAB 一个进程那样,具体规则后续再做分析。


简单的分析方法:

adb 链接手机之后, adb shell top | grep chrome  来查看 chrome 的生命周期

1. 打开 Chrome,会开启一个空tab, 此时会创建两个进程,两次刷新的结果如下:

14038  0   0% S    13 682096K  28364K  fg u0_a8    com.android.chrome
14038  3   6% S    31 723816K  59464K  fg u0_a8    com.android.chrome
14055  0   0% S    14 721328K  51724K  fg u0_i41   com.android.chrome:sandboxed_process0
14038  2  22% S    31 723816K  63708K  fg u0_a8    com.android.chrome
14055  0   0% S    14 721328K  51724K  fg u0_i41   com.android.chrome:sandboxed_process0
14038  2   0% S    31 723816K  63520K  fg u0_a8    com.android.chrome
14055  0   0% S    14 721328K  51724K  fg u0_i41   com.android.chrome:sandboxed_process0
14038  0   1% S    31 723816K  63520K  fg u0_a8    com.android.chrome

2. 如果把创建的tab 关闭,则仅剩下一个进程:

14038  0   0% S    31 716252K  59408K  fg u0_a8    com.android.chrome

3. 输入网址 m.baidu.com,发现启动了 sandboxed_process0 关闭了,启动一个 sandboxed_process1进程:

14038  0   2% S    44 736976K  65128K  fg u0_a8    com.android.chrome
14388  1   1% S    14 714468K  45816K  fg u0_i43   com.android.chrome:sandboxed_process1
14038  1   3% S    44 736976K  65160K  fg u0_a8    com.android.chrome
14388  1   2% S    14 714468K  46020K  fg u0_i43   com.android.chrome:sandboxed_process1
14038  0   5% S    44 736976K  65196K  fg u0_a8    com.android.chrome
14388  1   2% S    14 714468K  46020K  fg u0_i43   com.android.chrome:sandboxed_process1
14038  0   8% S    44 736976K  65232K  fg u0_a8    com.android.chrome
14388  1   5% S    14 714468K  46020K  fg u0_i43   com.android.chrome:sandboxed_process1


再次打开一个新的 tab, 发现有启动了一个 sandboxed_process0
14038  1   4% S    45 738184K  69832K  fg u0_a8    com.android.chrome
14805  1   1% S    14 719604K  49680K  fg u0_i44   com.android.chrome:sandboxed_process0
14388  1   0% S    14 707288K  39920K  fg u0_i43   com.android.chrome:sandboxed_process1
14038  0  16% S    45 738184K  69836K  fg u0_a8    com.android.chrome
14388  1   0% S    14 707288K  40184K  fg u0_i43   com.android.chrome:sandboxed_process1
14805  1   0% S    14 719604K  49680K  fg u0_i44   com.android.chrome:sandboxed_process0
14388  1   0% S    14 707288K  40184K  fg u0_i43   com.android.chrome:sandboxed_process1

再输入一个网址:
14038  0   0% S    45 738880K  70432K  fg u0_a8    com.android.chrome
14388  1   0% S    14 707288K  40180K  fg u0_i43   com.android.chrome:sandboxed_process1
14841  0   1% S    14 726272K  58548K  fg u0_i45   com.android.chrome:sandboxed_process2

再打开一个 tab :
14038  2  26% S    45 739200K  71408K  fg u0_a8    com.android.chrome
14841  0   0% S    14 716800K  50188K  fg u0_i45   com.android.chrome:sandboxed_process2
14388  1   0% S    14 707288K  40184K  fg u0_i43   com.android.chrome:sandboxed_process1
15029  0   0% S    14 719680K  49864K  fg u0_i46   com.android.chrome:sandboxed_process0

将Chrome 切换到后台,发现只剩下一个进程,并且占用内存也不算太大。
14038  1   0% S    44 730760K  64444K  bg u0_a8    com.android.chrome
14038  1   0% S    44 730760K  64444K  bg u0_a8    com.android.chrome
14038  1   0% S    44 730760K  64444K  bg u0_a8    com.android.chrome
14038  1   0% S    44 730760K  64556K  bg u0_a8    com.android.chrome
14038  1   0% S    44 730760K  64556K  bg u0_a8    com.android.chrome


  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值