Android 应用进程在 运行 一段时间后自动终止
Android application process gets killed automatically after running for some time
我的 android 应用程序在 运行 一段时间后(1 小时)自动终止,这是进程终止时打印到控制台的日志。 Process <package name> (PID 21659) has died
,并且在我的应用程序被杀死之前还有其他与我的应用程序无关的服务被杀死。这是因为 CPU 可用资源不足吗?
日志
09-10 17:34:49.959 1601 20644 I ActivityManager Process com.qti.csm (pid 20762) has died
09-10 17:34:49.959 1601 20644 D ActivityManager cleanUpApplicationRecord -- 20762
09-10 17:34:49.960 1601 20644 W ActivityManager Scheduling restart of crashed service com.qti.csm/.securityLog.RunTask in 66531ms
09-10 17:34:50.670 1601 13143 I ActivityManager Process com.razorlabs.cpumeter (pid 23212) has died
09-10 17:34:50.670 1601 13143 D ActivityManager cleanUpApplicationRecord -- 23212
09-10 17:34:50.680 1601 13143 W ActivityManager Scheduling restart of crashed service com.razorlabs.cpumeter/.services.ServiceWorker in 75810ms
09-10 17:34:50.695 1601 9564 I ActivityManager Process com.android.inputmethod.latin (pid 23423) has died
09-10 17:34:50.695 1601 9564 D ActivityManager cleanUpApplicationRecord -- 23423
09-10 17:34:50.695 1601 9564 W ActivityManager Scheduling restart of crashed service com.android.inputmethod.latin/.LatinIME in 85795ms
09-10 17:34:50.774 1601 1601 W InputMethodManagerService Session failed to close due to remote exception
09-10 17:34:50.774 1601 1601 W InputMethodManagerService android.os.DeadObjectException
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at android.os.BinderProxy.transactNative(Native Method)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at android.os.BinderProxy.transact(Binder.java:615)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.internal.view.IInputMethodSession$Stub$Proxy.finishSession(IInputMethodSession.java:305)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.server.InputMethodManagerService.finishSessionLocked(InputMethodManagerService.java:1631)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.server.InputMethodManagerService.clearClientSessionLocked(InputMethodManagerService.java:1622)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.server.InputMethodManagerService.clearCurMethodLocked(InputMethodManagerService.java:1648)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.server.InputMethodManagerService.onServiceDisconnected(InputMethodManagerService.java:1667)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at android.app.LoadedApk$ServiceDispatcher.doDeath(LoadedApk.java:1469)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1483)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at android.os.Handler.handleCallback(Handler.java:751)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at android.os.Handler.dispatchMessage(Handler.java:95)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at android.os.Looper.loop(Looper.java:154)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.server.SystemServer.run(SystemServer.java:363)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.server.SystemServer.main(SystemServer.java:230)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at java.lang.reflect.Method.invoke(Native Method)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
ActivityManager Process android.ext.services (pid 2274) has died
ActivityManager Process com.qualcomm.qcrilmsgtunnel (pid 2028) has died
ActivityManager Process com.android.smspush (pid 2093) has died
设备信息:
处理器:高通骁龙625
操作系统:AndroidN
您是否更改过使用 PackageManager 对象?
我遇到了同样的问题,结果发现使用这个对象有一个奇怪的错误,如果你使用它太多它可能会“死”并导致你的应用程序也收到“死对象异常”。
如果不是,我建议您尝试注释掉您可能在此异常之前添加的行,并尝试找出导致该问题的原因。
另外,如果可以向我们提供代码,那将有所帮助
丹·巴鲁克,感谢您的回复。我发现我的 JNI 代码中存在内存泄漏,这就是 android 终止我的服务和应用程序的原因。奇怪的是,内存泄漏发生得非常缓慢,并且没有日志表明这是因为 内存不足
我的 android 应用程序在 运行 一段时间后(1 小时)自动终止,这是进程终止时打印到控制台的日志。 Process <package name> (PID 21659) has died
,并且在我的应用程序被杀死之前还有其他与我的应用程序无关的服务被杀死。这是因为 CPU 可用资源不足吗?
日志
09-10 17:34:49.959 1601 20644 I ActivityManager Process com.qti.csm (pid 20762) has died
09-10 17:34:49.959 1601 20644 D ActivityManager cleanUpApplicationRecord -- 20762
09-10 17:34:49.960 1601 20644 W ActivityManager Scheduling restart of crashed service com.qti.csm/.securityLog.RunTask in 66531ms
09-10 17:34:50.670 1601 13143 I ActivityManager Process com.razorlabs.cpumeter (pid 23212) has died
09-10 17:34:50.670 1601 13143 D ActivityManager cleanUpApplicationRecord -- 23212
09-10 17:34:50.680 1601 13143 W ActivityManager Scheduling restart of crashed service com.razorlabs.cpumeter/.services.ServiceWorker in 75810ms
09-10 17:34:50.695 1601 9564 I ActivityManager Process com.android.inputmethod.latin (pid 23423) has died
09-10 17:34:50.695 1601 9564 D ActivityManager cleanUpApplicationRecord -- 23423
09-10 17:34:50.695 1601 9564 W ActivityManager Scheduling restart of crashed service com.android.inputmethod.latin/.LatinIME in 85795ms
09-10 17:34:50.774 1601 1601 W InputMethodManagerService Session failed to close due to remote exception
09-10 17:34:50.774 1601 1601 W InputMethodManagerService android.os.DeadObjectException
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at android.os.BinderProxy.transactNative(Native Method)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at android.os.BinderProxy.transact(Binder.java:615)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.internal.view.IInputMethodSession$Stub$Proxy.finishSession(IInputMethodSession.java:305)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.server.InputMethodManagerService.finishSessionLocked(InputMethodManagerService.java:1631)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.server.InputMethodManagerService.clearClientSessionLocked(InputMethodManagerService.java:1622)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.server.InputMethodManagerService.clearCurMethodLocked(InputMethodManagerService.java:1648)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.server.InputMethodManagerService.onServiceDisconnected(InputMethodManagerService.java:1667)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at android.app.LoadedApk$ServiceDispatcher.doDeath(LoadedApk.java:1469)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1483)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at android.os.Handler.handleCallback(Handler.java:751)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at android.os.Handler.dispatchMessage(Handler.java:95)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at android.os.Looper.loop(Looper.java:154)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.server.SystemServer.run(SystemServer.java:363)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.server.SystemServer.main(SystemServer.java:230)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at java.lang.reflect.Method.invoke(Native Method)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
09-10 17:34:50.774 1601 1601 W InputMethodManagerService at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
ActivityManager Process android.ext.services (pid 2274) has died
ActivityManager Process com.qualcomm.qcrilmsgtunnel (pid 2028) has died
ActivityManager Process com.android.smspush (pid 2093) has died
设备信息: 处理器:高通骁龙625 操作系统:AndroidN
您是否更改过使用 PackageManager 对象? 我遇到了同样的问题,结果发现使用这个对象有一个奇怪的错误,如果你使用它太多它可能会“死”并导致你的应用程序也收到“死对象异常”。 如果不是,我建议您尝试注释掉您可能在此异常之前添加的行,并尝试找出导致该问题的原因。 另外,如果可以向我们提供代码,那将有所帮助
丹·巴鲁克,感谢您的回复。我发现我的 JNI 代码中存在内存泄漏,这就是 android 终止我的服务和应用程序的原因。奇怪的是,内存泄漏发生得非常缓慢,并且没有日志表明这是因为 内存不足