简体   繁体   English

从服务中杀死Android中的所有后台进程是否安全?

[英]Is it safe to kill all background processes in Android from a service?

I am trying to do safe process killing for salvaging memory. 我试图做安全的进程杀死以挽救内存。 Is it safe to kill all background processes in a an activity by calling either ActivityManager.killBackgroundProcesses or IActivityManager.killAllBackgroundProcesses ? 通过调用ActivityManager.killBackgroundProcessesIActivityManager.killAllBackgroundProcesses杀死活动中的所有后台进程是否安全? I know it is painful in case one of the killed processes needs to be restarted, but is it safe? 我知道万一其中一个被杀死的进程需要重新启动是很痛苦的,但是这样做安全吗? Is it possible that something crucial to system performance or user/system data will be lost? 是否可能丢失对系统性能或用户/系统数据至关重要的内容?

I am trying to do safe process killing for salvaging memory 我试图做安全的进程杀死以挽救内存

The OS will terminate processes as needed to free up system memory. 操作系统将根据需要终止进程以释放系统内存。 You do not need to do so yourself. 您无需自己这样做。 By the time your process runs, there is enough memory to run your process. 在您的进程运行时,有足够的内存来运行您的进程。

Is it possible that something crucial to system performance or user/system data will be lost? 是否可能丢失对系统性能或用户/系统数据至关重要的内容?

It is certainly possible that user data will be lost. 当然,用户数据可能会丢失。 For example, if they were in the middle of a form, switched to some other application for a moment, and you decide to kill all background processes, they may well lose what they entered. 例如,如果它们在表单中间,暂时切换到其他应用程序,而您决定杀死所有后台进程,则它们很可能会丢失输入的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM