关于java:即使应用程序被杀,我们是否可以获得内存泄漏?

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

如果进程被终止,如果我们在onStop中没有发布代码,我们怎么能得到内存泄漏? 在app杀死所有资源都清理好了吗?


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和线程无关的东西。 例如,如果用户已将数据输入到您要保留但尚未保留的应用程序中,则onStop()是考虑分叉线程将该内容保存到磁盘的候选时间。


如果进程被杀死。 所有相关的内存内容都将从系统中删除,因此终止进程不会泄漏内存。