Android 12 应用程序允许使用多少 RAM?

How much RAM is an Android 12 app allowed to use?

Android12 是否对单个应用程序可以使用多少 RAM 设置了任何限制? 您当然会受到设备上可用 RAM 数量的限制。但是 Android 12 是否设置任何上限,无论可用什么?

Does Android 12 set any limits on how much RAM a single app can use?

Java/Kotlin 代码对可用堆大小有限制。引用 the documentation:

To allow multiple running processes, Android sets a hard limit on the heap size alloted for each app. The exact heap size limit varies between devices based on how much RAM the device has available overall. If your app has reached the heap capacity and tries to allocate more memory, the system throws an OutOfMemoryError.

本机 (NDK) 代码不使用 VM 堆并且没有限制,除了可用的系统 RAM。

请注意,none 是 Android 12 的新功能 — 这些限制已经存在很长时间了。