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

java– 即使应用程序被杀,我们是否可以获得内存泄漏?,第1张

概述我无法理解Activity.onStop()的这句话:WhenyouractivityreceivesacalltotheonStop()method,it’snolongervisibleandshouldreleasealmostallresourcesthataren’tneededwhiletheuserisnotusingit.Onceyouractivityisstopped,thesyste

我无法理解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()是考虑分配线程以将该内容保存到磁盘的候选时间.

总结

以上是内存溢出为你收集整理的java – 即使应用程序被杀,我们是否可以获得内存泄漏?全部内容,希望文章能够帮你解决java – 即使应用程序被杀,我们是否可以获得内存泄漏?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1110860.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存