Low-memory games insights

Android sometimes kills (or terminates) top, high-fidelity games when the device is short on memory. Android tries to use all available memory to cache apps and games to ensure they load quickly (improving the user experience), but when memory becomes limited, the system kills the most memory-intensive apps and games to free up memory for normal device operation.

Information, insights, and best practices to help you achieve better game memory usage include the following

  • Use ApplicationExitInfo — This Java/Kotlin API returns the reason why the previous game run was killed by the Android system. Use ApplicationExitInfo to check for low memory as a reason for a previous process run death. Check whether the game was killed due to low memory, so the game can be optimized to use less memory on that device.
  • Look at total physical RAM — To prevent games from being killed when in the foreground and to match the device's capabilities, look at the total physical RAM, and adjust game memory usage based on that. If the goal is to prevent apps from being killed shortly after moving to the background (to allow the player to multitask), use the trim callbacks (TRIM_MEMORY_UI_HIDDEN specifically) to reduce your game memory usage.
  • Don't register for deprecated trim callbacks — Android doesn't have any APIs for detecting native memory pressure events when they're running into memory limits (see the Low memory killer daemon callout). Trim callbacks haven't been helpful at preventing low-memory kills, so Android deprecated all of them, other than TRIM_MEMORY_UI_HIDDEN and TRIM_MEMORY_BACKGROUND.

Low memory killer daemon

The Android low memory killer daemon (lmkd) is a process that monitors memory state of a running Android system and reacts to high memory pressure by killing the least essential processes to keep the system performing at acceptable levels.

The daemon can pick processes to kill without waiting for the process to acknowledge any kind of callback. Thus, apps and games will not receive a notification as a last chance to release memory before they are killed.

Learn more about the low memory killer daemon.