我的应用程序有三个进程和两个服务,它们的关系如下:( UI启动并绑定BKService,UI启动和绑定LinkService,然后BKService绑定LinkService)
Daemon Process (BKService) / /(bind A) | UI process | (bind C) \ (bind B) | \ Push Process (LinkService)
和推送过程的内存使用量远远小于守护进程。
我使用dumpsys活动进程来检查它们的adj类型和值,如下所示:
Proc # 7: svc B/ /S trm: 5 1998:cc.okcall:daemon/u0a155 (started-services)
Proc # 6: svc B/ /S trm: 5 2017:cc.okcall:push/u0a155 (started-services)
Proc # 5: cch+1 B/ /CA trm:80 2697:cc.okcall/u0a155 (cch-act)
这里是详细的dumpsys活动流程信息:
*APP* UID 10155 ProcessRecord{4297b510 12359:cc.okcall/u0a155}
user #0 uid=10155
class=cc.okcall.MyApplication
dir=/data/app/cc.okcall-1.apk publicDir=/data/app/cc.okcall-1.apk data=/data/data/cc.okcall
packageList={cc.okcall}
compat={320dpi}
thread=android.app.ApplicationThreadProxy@42970828
pid=12359 starting=false
lastActivityTime=-6m44s889ms lastPssTime=-3m57s159ms nextPssTime=+26m2s662ms
adjSeq=449275 lruSeq=0 lastPss=20116 lastCachedPss=20116
keeping=false cached=true empty=true
oom: max=16 curRaw=10 setRaw=10 cur=10 set=10
curSchedGroup=0 setSchedGroup=0 systemNoUi=false trimMemoryLevel=0
curProcState=11 repProcState=11 pssProcState=10 setProcState=11 lastStateTime=-6m39s857ms
hasShownUi=true pendingUiClean=false hasAboveClient=false
lastWakeTime=0 timeUsed=0
lastCpuTime=0 timeUsed=0
lastRequestedGc=-9m44s117ms lastLowMemory=-9m44s117ms reportLowMemory=false
Activities:
- ActivityRecord{4285f6b8 u0 cc.okcall/.ui.home.ActivityHome t140}
Connections:
- ConnectionRecord{428a5048 u0 CR cc.okcall/.push.LinkService:@4236a318}
- ConnectionRecord{428f3300 u0 CR cc.okcall/.service.BKService:@42383ef8}
- ConnectionRecord{42baac98 u0 CR cc.okcall/.push.LinkService:@4236a318}
- ConnectionRecord{42bb4dc0 u0 CR cc.okcall/.service.BKService:@42383ef8}
Connected Providers:
- 4217c8b8/com.android.providers.settings/.SettingsProvider->12359:cc.okcall/u0a155 s1/1 u0/0 +9m43s423ms
- 4216e458/com.motorola.android.providers.settings/.MotorolaSettingsProvider->12359:cc.okcall/u0a155 s1/1 u0/0 +9m43s330ms
Receivers:
- ReceiverList{4293d538 12359 cc.okcall/10155/u0 remote:4294d840}
*APP* UID 10155 ProcessRecord{429e1778 12416:cc.okcall:push/u0a155}
user #0 uid=10155
class=cc.okcall.MyApplication
dir=/data/app/cc.okcall-1.apk publicDir=/data/app/cc.okcall-1.apk data=/data/data/cc.okcall
packageList={cc.okcall}
compat={320dpi}
thread=android.app.ApplicationThreadProxy@4225b430
pid=12416 starting=false
lastActivityTime=-9m40s498ms lastPssTime=-4m6s679ms nextPssTime=+15m53s244ms
adjSeq=449275 lruSeq=0 lastPss=9259 lastCachedPss=0
keeping=true cached=false empty=true
oom: max=16 curRaw=5 setRaw=5 cur=5 set=5
curSchedGroup=0 setSchedGroup=0 systemNoUi=false trimMemoryLevel=0
curProcState=7 repProcState=7 pssProcState=7 setProcState=7 lastStateTime=-6m39s867ms
hasClientActivities=true foregroundActivities=false
hasStartedServices=true
lastRequestedGc=-9m42s433ms lastLowMemory=-9m42s433ms reportLowMemory=false
Services:
- ServiceRecord{43147398 u0 cc.okcall/.push.LinkService}
Connected Providers:
- 4217c8b8/com.android.providers.settings/.SettingsProvider->12416:cc.okcall:push/u0a155 s1/1 u0/0 +9m41s11ms
Receivers:
- ReceiverList{42982798 12416 cc.okcall:push/10155/u0 remote:42555c68}
- ReceiverList{42d1b248 12416 cc.okcall:push/10155/u0 remote:42d1b028}
*APP* UID 10155 ProcessRecord{42d66170 12195:cc.okcall:daemon/u0a155}
user #0 uid=10155
class=cc.okcall.MyApplication
dir=/data/app/cc.okcall-1.apk publicDir=/data/app/cc.okcall-1.apk data=/data/data/cc.okcall
packageList={cc.okcall}
compat={320dpi}
thread=android.app.ApplicationThreadProxy@42abfc68
pid=12195 starting=false
lastActivityTime=-9m40s601ms lastPssTime=-4m6s757ms nextPssTime=+15m53s144ms
adjSeq=449275 lruSeq=0 lastPss=19601 lastCachedPss=0
keeping=true cached=false empty=true
oom: max=16 curRaw=5 setRaw=5 cur=5 set=5
curSchedGroup=0 setSchedGroup=0 systemNoUi=false trimMemoryLevel=0
curProcState=7 repProcState=7 pssProcState=7 setProcState=7 lastStateTime=-6m39s967ms
hasClientActivities=true foregroundActivities=false
hasStartedServices=true
lastRequestedGc=-9m48s171ms lastLowMemory=-9m48s171ms reportLowMemory=false
Services:
- ServiceRecord{431d5770 u0 cc.okcall/.service.BKService}
Connections:
- ConnectionRecord{42d455f0 u0 cc.okcall/.push.LinkService:@41f9aa40}
Published Providers:
- cc.okcall.provider.AccountProvider
-> ContentProviderRecord{42f4d1e0 u0 cc.okcall/.provider.AccountProvider}
- cc.okcall.provider.MessageProvider
-> ContentProviderRecord{42f4d278 u0 cc.okcall/.provider.MessageProvider}
- cc.okcall.provider.MeetupProvider
-> ContentProviderRecord{42f4d310 u0 cc.okcall/.provider.MeetupProvider}
- cc.okcall.provider.ContactProvider
-> ContentProviderRecord{42f4d3a8 u0 cc.okcall/.provider.ContactProvider}
Connected Providers:
- 4217c8b8/com.android.providers.settings/.SettingsProvider->12195:cc.okcall:daemon/u0a155 s1/1 u0/0 +9m41s118ms
Receivers:
- ReceiverList{42a3ed60 12195 cc.okcall:daemon/10155/u0 remote:421374c0}
好吧,据我所知,在内存不足的情况下,查杀序列应该是:UI进程,守护程序进程,推送进程。 (因为BKService是LinkService的客户端,所以LinkService在unBind之前不会死,并且使用相同的oom_adj值,LinkService使用更少的内存)。
但实际上杀戮序列总是:UI进程,推送进程,守护进程。有人可以解释一下吗?
如果我改变了绑定C的方向(LinkService绑定BKService),那么守护进程将比推进进程更早被杀死。
我无法弄清楚原因,有人可以提供帮助,提前谢谢。