Can we get a memory leak even if the app is killed?
我无法理解Activity.onStop()中的这个陈述:
When your activity receives a call to the onStop() method, it's no
longer visible and should release almost all resources that aren't
needed while the user is not using it. Once your activity is stopped,
the system might destroy the instance if it needs to recover system
memory. In extreme cases, the system might simply kill your app
process without calling the activity's final onDestroy() callback, so
it's important you use onStop() to release resources that might leak
memory.
特别是这部分:
In extreme cases, the system might simply kill your app process
without calling the activity's final onDestroy() callback, so it's
important you use onStop() to release resources that might leak memory
如果进程被终止,如果我们在
If the process is killed how can we get a memory leak if we don’t have release code in onStop?
你不能。 Android文档gots问题,哟。
On app kill all resources are cleaned right?
好吧,你的进程终止了,这消除了你的RAM和线程。 你需要做的是安排清理任何与RAM和线程无关的东西。 例如,如果用户已将数据输入到您要保留但尚未保留的应用程序中,则
如果进程被杀死。 所有相关的内存内容都将从系统中删除,因此终止进程不会泄漏内存。