priority代表终止优先级,0代表前台应用,从高到低依次终止。
kill_reason=LowMemoryKill, killing proc[pid=xxx, uid=xxx, procName=com.hx.example, priority=xxx type=x], freedBuf=xxx
StabilityCheckKill是6.0新增的memmgr终止机制,区别LowMemoryKill仅包含能快速回收的内存,可以提供给用户态使用。
KillOneProcessByPid process com.hx.example has been Killed, isAncoApp=0, errno=0, pid=23348, freedSize=5391580 KB, rssKB:222888, rssAnonKB:107760, dmaKB:5164672, gpuKB=119148, pssKB=0, childrenFreedKB=0, useAmsKill=0, amsKillResult=-1, useBrokerKill=0, brokerKillResult=-1, useMemmgrKill=1, memmgrKillResult=0, reason=StabilityCheckKill
同LowMemoryKill,根据priority,从优先级最低的应用进行终止。
C02699/memmgrservice/MemMgr: KillHelper::WriteKillEvent hisysevent write result=0, send event [FRAMEWORK,PROCESS_KILL], pid=36844, processName=com.hx.example, msg=Kill reason: SWAP_FULL; Current buffer is: 1683456; Freed buffer is: 85436; Killed process [uid is: 20020277, priority is: 382, type is: 3, diffTimeMs is: 1156471], foreground=0
参考文档获取进程内存信息,找到占用SWAP内存最大的应用,再通过Profiler工具中的Snapshot模板,排查是否存在可疑的泄漏对象。
C01713/resource_schedule_service/SUSPEND_MANAGER: [(ReportKillAppEvent):267] hisysevent write result=0, send event [FRAMEWORK,PROCESS_KILL], pid=30627, processName=com.hm.example, msg=Kill Reason:ILLEGAL_AUDIO_RENDERER_BY_SUSPEND
C01713/resource_schedule_service/SUSPEND_MANAGER: [(ReportKillAppEvent):277] hisysevent write result=0, send event [FRAMEWORK,PROCESS_KILL], pid=64424, processName=com.hm.example, msg=Kill Reason:ILLEGAL_AUDIO_CAPTURER_BY_SUSPEND, foreground=0
C01336/foundation/AMS: [app_exit_reason_data_manager.cpp:220]current bundle name: com.hx.example, tokenId:<private>, reason: 6, exitMsg: Kill Reason:Power Save Clean, abilityName:EntryAbility isSetReason:1
C01716/resource_schedule_service/RESOURCE_QUOTA_CONTROL: [a92ab77a9eb01c1 0 0][KillApplication:158] hisysevent write result=0, send event [FRAMEWORK,PROCESS_KILL], uid=1000080, pid=38811, processName=com.hx.example:render, KillReason=Kill Reason:CPU Highload, Msg=, FOREGROUND=0
参考文档分析内存占用问题,找出内存占用过高的应用,再使用Snapshot和Allocation工具分析应用内存使用情况,及时释放不必要的内存资源,如需要排查是否存在内存泄漏问题,可参考内存泄漏类问题检测方法。
参考文档分析内存占用问题,找出内存占用过高的应用,再使用Snapshot和Allocation工具分析应用内存使用情况,及时释放不必要的内存资源,如需要排查是否存在内存泄漏问题,可参考内存泄漏类问题检测方法。
如果后台进程个数太多且无应用内存占比过高,则是系统正常策略,可通过关闭其它应用,保持系统SWAP空间正常避免。
如果分析出个别应用进程内存泄漏,根据相应场景,参考资源泄漏类问题优化建议进行修改。
参考后台播放音乐中的示例,申请长时任务播放音频,禁止不操作或写入静音数据等恶意行为。
降低应用自身的CPU负载,参考CPU活动分析:CPU分析,使用Profiler工具分析CPU资源使用情况,相关案例参考CPU 高负载分析。