gpt4 book ai didi

java - 以编程方式清除缓存的后台进程

转载 作者:太空宇宙 更新时间:2023-11-03 13:52:58 26 4
gpt4 key购买 nike

我开发了一个简单的应用程序,可以并排加载四个移动 WebView 。在全新安装时,该应用程序会在 0.5 秒内完全打开并加载这些页面。但是,如果我最小化这个应用程序,由于某种原因,它的“缓存后台进程”超过 200mbs!有时 250... 似乎完全没有必要,因为应用程序在全新安装时加载速度快如闪电

如何在应用程序最小化(onbackpressed 等)时清除此缓存

enter image description here

最佳答案

您无需担心缓存内存,因为系统会在需要时回收它。

但是,如果您仍然想对此做些什么,您可以在 onStop() 方法中调用 finish()

还有this is a great answer关于这个话题 CommonsWare .

"cached background processes" usually refers to processes that do not have a foreground activity and do not have a running service. These processes are kept in memory simply because we have enough memory to do so, and therefore, as you note, the user can switch back to these processes quickly. As Android starts to need more system RAM for yet other processes, the "cached background processes" tend to be the processes that get terminated to free up system RAM

关于java - 以编程方式清除缓存的后台进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32924167/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com