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

Programmatically clear cached background process

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

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

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

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

还有this is a great answer on this topic by 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