Does Android 12 set any limits on how much RAM a single app can use? You are of cause limited by the the amount of available RAM on your device. But does Android 12 set any upper limits, no matter what is available?
CodePudding user response:
Does Android 12 set any limits on how much RAM a single app can use?
Java/Kotlin code has limits on the available heap size. Quoting 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
.
Native (NDK) code is not using the VM heap and has no limit, other than available system RAM.
Note that none of this is new to Android 12 — these limitations have been in place for a very long time.