我们可以得到,即使应用程序被杀害的内存泄漏? [英] Can we get a memory leak even if the app is killed?

查看:183
本文介绍了我们可以得到,即使应用程序被杀害的内存泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白从 Activity.onStop这个说法()


  

当你的活动收到调用的onStop()方法,这也
  不再可见,应该释放几乎所有的资源都没有
  当用户不使用它需要的。一旦你的活动已停止,
  如果需要恢复系统的系统可能会破坏该实例
  记忆。在极端的情况下,系统可能只是杀了你的应用程序
  无需调用该活动的最后的onDestroy()回调的过程,所以
  这一点很重要,你使用的onStop()来释放可能泄漏资源
  内存。


具体该部分:


  

在极端的情况下,系统可能只是杀了你的应用程序
  无需调用该活动的最后的onDestroy()回调,所以它的
  重要的是你使用的onStop()来释放可能泄漏内存资源


如果该进程被终止,我们怎样才能得到,如果我们没有在的onStop 释放code内存泄漏?在应用杀死所有的资源都打扫吧?


解决方案

  

如果该进程被终止,我们怎样才能得到一个内存泄漏,如果我们不具备的onStop释放code?


您不能。 Android的文档GOTS问题哟。


  

在应用杀死所有的资源都打扫吧?


那么,你的进程被终止,免去您的内存和线程。你需要做的是安排清理任何的不是的与您的内存和线程。例如,如果用户输入数据转换为要保留,并没有持续的应用程序,的onStop()是候选人的时间来考虑分叉线程保存这些东西到磁盘。

I can not understand this statement from 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.

Specifically this part:

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? On app kill all resources are cleaned right?

解决方案

If the process is killed how can we get a memory leak if we don’t have release code in onStop?

You can't. The Android documentation gots issues, yo.

On app kill all resources are cleaned right?

Well, your process is terminated, which eliminates your RAM and threads. What you need to do is arrange to clean up anything that isn't tied to your RAM and threads. For example, if the user has entered data into the app that you want to keep and have not persisted yet, onStop() is a candidate time to consider forking the thread to save that stuff to disk.

这篇关于我们可以得到,即使应用程序被杀害的内存泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆