gpt4 book ai didi

android - 当内存不足时,android 会销毁单个 Activity 还是整个堆栈?

转载 作者:行者123 更新时间:2023-11-29 16:51:05 25 4
gpt4 key购买 nike

正如标题所说,当 android 内存不足时究竟会发生什么?它是随机选择 Activity 并终止它们,还是终止应用程序的整个后台堆栈。

我担心我在我的应用程序中的 Activity 历史不会被妥善保存(例如,个人资料页面出现在编辑图片页面之前)

最佳答案

它杀死了整个过程,而不仅仅是一些 Activity 。如果操作系统决定终止您的应用程序正在运行的进程,您的应用程序将作为一个整体被终止。

如果你通过Processes and Application Lifecycle

In most cases, every Android application runs in its own Linux process. This process is created for the application when some of its code needs to be run, and will remain running until it is no longer needed and the system needs to reclaim its memory for use by other applications.

此外,如果您通过 Processes and Threads

By default, all components of the same application run in the same process and most applications should not change this. ... Android might decide to shut down a process at some point, when memory is low and required by other processes that are more immediately serving the user.

希望对您有所帮助。

关于android - 当内存不足时,android 会销毁单个 Activity 还是整个堆栈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46435406/

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